Sorted and reversed on huge dict ?

vd12005 at yahoo.fr vd12005 at yahoo.fr
Sat Nov 4 10:38:50 EST 2006


just to be sure about intern, it is used as :

>>> d, f = {}, {}
>>> s = "this is a string"
>>> d[intern(s)] = 1
>>> f[intern(s)] = 1

so actually the key in d and f are a pointer on an the same intern-ed
string? if so it can be interesting,

>>> print intern.__doc__
intern(string) -> string

``Intern'' the given string.  This enters the string in the (global)
table of interned strings whose purpose is to speed up dictionary
lookups.
Return the string itself or the previously interned string object with
the
same value.

the comment here: "(Changed in version 2.3: Interned strings used to be
immortal, but you now need to keep a reference to the interned string
around.)", if it the string is used as a key, it is still reference-d,
am i right?




More information about the Python-list mailing list