Reputation: 838
I want to write a decorator that does persistent memoization (memoizing to disk). Since I want to use this decorator for many functions, I have to decide where to save memoizing data for these functions. I googled around and found two solutions:
However, in these two solutions, it is necessary for every function to "know" each other in case of colliding of names (or destinations), which is a smell of bad design.
Thus, my question is, how to avoid such collidings?
Upvotes: 0
Views: 82
Reputation: 43117
Save it in something next to or related to __file__
, which is the path to the file the module was loaded from. I believe in some cases it can be a relative path, so you might want to store the memos in that path directly, or turn it into an absolute path or something.
Upvotes: 1