Conversation
|
Woah this is a really nice change! It would definitely make things more ergonomic! I have a few minor changes in mind but I suppose we should first try to use it to replace our current caching and see if we need to make any changes. Could you elaborate about numba and numpy? Where and when does it complain? I can help out with integrating this decorator :) |
|
That's great to hear! What kind of changes do you think should be done? About numba, when trying to run From what I could find online, the next numba release will support numpy 2.1, but I'm not sure when that will be out. |
Ah I see! Sorry, I misunderstood as I was not aware of the use of numba, but I think it is used in the
I think the only things I would change right now are the names, to make it really explicit what is happening. For example, we could call the decorator I think that the most important thing now is to see if it is actually ergonomic by refactoring a small piece of code to use this cache. Let me know if I can help out with that! |
Created a decorator that can be used to cache the first value of instance method calls, without taking any parameters besides
selfinto consideration. It is also possible to specify a "default value" to be returned after the first method call using a keyword argument.While it is not possible to apply to every method that requires caches, it might be nice for simpler methods.
Before:
After:
It is possible to clear the cache of all values, or only for a subset of methods:
Finally, while testing some circuits,
numbacomplained about currently not supportingnumpy 2.1and above, which is why I updated therequirements.txt.