Python Forum

Full Version: i wish there was
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i wish there was a way to have a function be able to do some big complex calculation to create a big data reference table that is exactly the same each time it is called and save it between calls to avoid repeating all that work each time it is called. i know i could save it in global space, but i'd have to code the function as a module and put some name in the caller's global space. it would have been nice for functions to each have their own way to save data between calls without polluting the caller's global namespace. i suppose i can make it be a class to do it. that's how pike does it. i better not mention that language with a one-letter name.
You could also do a closure.