I do that in a part of my code, and I need to handle the logic of first looking at that dictionary, and if it's not there, calculate it and store it in the dictionary. Is this what you meant? That's what I'm trying to avoid, doing all that manual work that a cache decorator is supposed to do for me in one line.
On Fri, Oct 16, 2020 at 11:45 AM Irit Katriel <[email protected]> wrote: > You can use a global WeakKeyDictionary keyed by the object to achieve the > same without having anything on the object. > > > On Friday, October 16, 2020, 09:37:05 AM GMT+1, Ram Rachum <[email protected]> > wrote: > > Did you mean like keeping a hidden attribute on the object with the > result? Well, that'd require manually keeping track of these attributes for > each method I'm caching. I do that sometimes, but it's verbose. > > >
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/BFVLUSGFBFFEOH4OZZKRASNSCGBNZH7T/ Code of Conduct: http://python.org/psf/codeofconduct/
