I'm writing a memoization of a function and I want to store an attribute in the function object. Will the function attribute be available for the lifespan of the process? if not how can I achieve such a thing?
Thank you
I'm writing a memoization of a function and I want to store an attribute in the function object. Will the function attribute be available for the lifespan of the process? if not how can I achieve such a thing?
Thank you
Copyright © 2021 Jogjafile Inc.
I interpret this question as "can I reasonably expect a user-defined attribute of a function object to persist through the entire lifetime of my program? For example, in this code:
... Is it guaranteed that f.x won't spontaneously lose its value halfway through?"
The
xattribute of the functionfwill retain its value for the entire lifetime off. Functions defined at the global scope live for the entire lifetime of the program. So you can safely usef.xfor memoization.