Version 4 of the Contracts Language API brings multiple performance improvements:
The blanket run-time type checking has been replaced with targeted custom validation only where necessary.
Multiple essential vault methods have been optimised and the performance improvements confirmed with contract execution benchmarking:
get_balances_timeseries is almost twice as fast as the Contracts Language version 3 equivalent when accessing the latest balance value of a specific coordinate.
The get_posting_instruction and get_client_transactions showed almost three times better performance compared to version 3, when accessing balances for each of the posting instructions or client transactions within the data interval.
The posting related custom types have been refactored and changed, so that they are independent of historical data when evaluating their attributes and balances. These changes enable a significant performance boost for hooks that access posting data or that relate to a postings journey. For example, the performance of the pre_posting_hook execution with no data fetching was almost four times faster compared to version 3.