On Mon, 2007-02-12 at 12:29 -0800, Josiah Carlson wrote:
> Hrvoje Nikšic <[EMAIL PROTECTED]> wrote:
> > 
> > I propose modifying PyString_InternInPlace to better cope with string
> > subtype instances.
> 
> Any particular reason why the following won't work for you?
[... snipped a simple intern implementation ...]

Because Python internals don't use that; they call
PyString_InternInPlace directly.

Another reason is that Python's interning mechanism is much better than
such a simple implementation: it stores the interned state directly in
the PyString_Object structure, so you can find out that a string is
already interned without looking it up in the dictionary.  This
information can (and is) used by both Python core and by C extensions.
Another advantage is that, as of recently, interned strings can be
garbage collected, which is typically not true of simple replacements
(although it could probably be emulated by using weak references, it's
not trivial.)


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to