On Nov 24, 4:59 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 24 Nov 2007 03:44:59 -0800, Licheng Fang wrote: > > On Nov 24, 7:05 pm, Bjoern Schliessmann <usenet- > > [EMAIL PROTECTED]> wrote: > >> Licheng Fang wrote: > >> > I find myself frequently in need of classes like this for two > >> > reasons. First, it's efficient in memory. > > >> Are you using millions of objects, or MB size objects? Otherwise, this > >> is no argument. > > > Yes, millions. > > Oh noes!!! Not millions of words!!!! That's like, oh, a few tens of > megabytes!!!!1! How will a PC with one or two gigabytes of RAM cope????? >
Comments like these make one wonder if your real life experience with massive data matches even the one tenth of your self-importance and need to be snarky in most of your posts. To the OP: yes, your use case is quite valid; the keyword you are looking for is "memoize". You can find around a dozen of recipes in the Cookbook and posted in this list; here's one starting point: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413717. HTH, George -- http://mail.python.org/mailman/listinfo/python-list