Dictionaries as records

Jason Orendorff jason at jorendorff.com
Wed Dec 19 00:37:12 EST 2001


> What strikes me as odd is that I can create a list of 200K 
> dictionaries with
> test data (a copy of the same record over and over) and the 
> amount of memory
> used is only half.

This might have nothing to do with dictionary memory management.

If you make 200,000 copies of
  { 'name': 'Jason', 'domain': 'jorendorff.com', 'age': '117' }

then you'll have 200,000 dictionaries, but only 6 strings.
All the dictionaries will contain pointers to the same 5 string
objects.

Of course when you're dealing with real data you create many
different string objects.

-- 
Jason Orendorff    http://www.jorendorff.com/





More information about the Python-list mailing list