Size in bytes of a dictionary

David Bolen db3l at fitlinxx.com
Wed Sep 19 19:27:47 EDT 2001


Don O'Donnell <donod at home.com> writes:

> Also beware of automatic interning of strings.  Of course this won't be
> an issue with your key strings, since they must be unique, but duplicate
> value strings may use the same memory location.  I'm not sure under what
> conditions auto-intern takes place but it seems to be related to the
> length of the string.  Here's a little test I just ran:

It's of course potentially version specific, but I think in all recent
(1.5.2+) variants of CPython the interning rule is that it must be a
string consisting soley of alphanumerics and the underscore.  Length
does not appear to be a factor.  (See compile.c in the CPython
source).

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list