You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if functools.lru_cache existed when we added galsim.utilities.LRU_Cache, but I've been playing around with it recently and I think I like it better. With this simple program:
I get better performance with functools.lru_cache (~1.0 s vs ~1.8 s), and also like the output I get through gprof2dot better:
utilities.LRU_Cache
functools.lru_cache
Querying the cache hits/misses is also nice with functools.lru_cache.
The one feature we'd be giving up is the ability to resize the already-created cache. It's definitely nice for the user to be able to set the size, so I think we'd need to invent some kind of API wrapper for that. Looks like there's a __wrapped__ attribute that might help.
Finally, functools.lru_cache is only available for python >3.2, so this would be easiest if we dropped support for 2.7.
The text was updated successfully, but these errors were encountered:
Agreed. I looked into this a bit for TreeCorr (where I already dropped 2.7 support on main), and for TreeCorr, I really do want the resize option, so I decided against switching there. But for GalSim, I was thinking we didn't really need that for the cases where we use this, so I'd be fine with dropping the ability to resize and switch over.
Or, if you feel like trying to figure out how to shoehorn the resizing in, that's also good by me.
I'm not sure if
functools.lru_cache
existed when we addedgalsim.utilities.LRU_Cache
, but I've been playing around with it recently and I think I like it better. With this simple program:I get better performance with
functools.lru_cache
(~1.0 s vs ~1.8 s), and also like the output I get through gprof2dot better:utilities.LRU_Cache
functools.lru_cache
Querying the cache hits/misses is also nice with
functools.lru_cache
.The one feature we'd be giving up is the ability to resize the already-created cache. It's definitely nice for the user to be able to set the size, so I think we'd need to invent some kind of API wrapper for that. Looks like there's a
__wrapped__
attribute that might help.Finally,
functools.lru_cache
is only available for python >3.2, so this would be easiest if we dropped support for 2.7.The text was updated successfully, but these errors were encountered: