Rethinking intern() for python

Michael Hudson michael.hudson at canonical.com
Wed Apr 8 06:45:35 BST 2009


John Arbash Meinel wrote:
> So one of the very interesting results of my memory profiling, is
> showing that intern() is a very inefficient structure, for a number of
> reasons. To give the specific values, after doing:
>   bzr branch A B
> of a small project, the total memory consumption is ~21MB

I don't have anything super exciting to add, but I should mention that
interning in CPython is mostly a /speed/ optimization, not a /space/
optimization.  If you can make the string that is looked up to find a
global variable the same string object as that which was used to define
the global, things go that little bit faster.

Cheers,
mwh



More information about the bazaar mailing list