Any problems with *lots* of attributes?

Michael Hudson mwh at python.net
Thu Feb 5 17:26:38 CET 2004


aahz at pythoncraft.com (Aahz) writes:

> In article <1024d7q40b86r2a at news.supernews.com>,
> John Roth <newsgroups at jhrothjr.com> wrote:
> >
> >I believe the memory overhead for dictionaries is 4 times that for
> >lists on a per item basis, however both data structures allocate
> >extra space so that they don't have to reallocate too frequently
> >(a very expensive operation.)
> 
> Should be only double; where do you get four times?  (Note that I'm
> talking strictly about the dict itself, not the space consumed by the
> keys.)

The hash is stored in the dictentry struct, which gets you to three
times; I suppose it's possible alignment would get you four but I
don't think so.

Cheers,
mwh

-- 
  I have no disaster recovery plan for black holes, I'm afraid.  Also
  please be aware that if it one looks imminent I will be out rioting
  and setting fire to McDonalds (always wanted to do that) and
  probably not reading email anyway.                     -- Dan Barlow



More information about the Python-list mailing list