2 ms·
Might be interesting as an option for the @lru_cache decorator to be able to specify a function to call before handing a cached value to the user. Then you coul
by Quekid5 5y ago
Might be interesting as an option for the @lru_cache decorator to be able to specify a function to call before handing a cached value to the user. Then you could just do
@lru_cache(post=deepcopy, ...)
to have a new (copied) instance in cases where that's required. Or do whatever else you needed. Maybe you happen to know some details about the returnee that would let you get away with copying less and could call my_copy instead.
Something something power of function composition.