Albert-Jan Roskam wrote: > [snip] > > Also, you should have some way to stop the lookup table from growing > > forever. > > If you are running Python 3.3, you can use functools.lru_cache, which > > implements a Least Recently Used cache. Once the cache reaches a certain > > size, > > the element which was least recently used is flushed. > > > > I read about that. Time to upgrade! Wish I could use this in the office! >
Why can you not? Even if you are not using Python3.2+ you should be able to back port it from the Python source. You may need to backport other features (e.g. OrderedDict) depending on the Python version you use. http://svn.python.org/projects/python/tags/r32b1/Lib/functools.py Alternatively, you can use Raymond Hettinger's recipe. At a brief glance, it looks to be Python 2.x compatible. http://code.activestate.com/recipes/498245/ ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor