mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-14 11:15:09 +08:00
Instead of using the `remember_last` memoization on all calls to `_find_position_of_minute`, add an instance local cache which is only used by the `get_value` call. The `get_value` call is very hot, so any extra overhead (e.g. creating the WeakArgs on every invocation) becomes costly. The current usage `get_value` also has the property that it is called with monotonically increasing, but with a high repeat count on each value. (A further improvement could making a `get_value` which supports being used by many sids, for use by the update portfolio positions.) The caching is not done at the `_find_position_of_minute_level` because `unadjusted_window` always uses two positions on the tape (start and end of range) which would cause the entries and removal into the cache which would be invalidated both between the calls of start and end, and next call of the function.