Patch #1601678: move intern() to sys.intern().

This commit is contained in:
Georg Brandl 2006-12-19 20:50:34 +00:00
parent 376446dd4e
commit 66a796e5ab
12 changed files with 81 additions and 73 deletions

View file

@ -340,6 +340,21 @@ else:
\versionadded{1.5.2}
\end{datadesc}
\begin{funcdesc}{intern}{string}
Enter \var{string} in the table of ``interned'' strings and return
the interned string -- which is \var{string} itself or a copy.
Interning strings is useful to gain a little performance on
dictionary lookup -- if the keys in a dictionary are interned, and
the lookup key is interned, the key comparisons (after hashing) can
be done by a pointer compare instead of a string compare. Normally,
the names used in Python programs are automatically interned, and
the dictionaries used to hold module, class or instance attributes
have interned keys. \versionchanged[Interned strings are not
immortal (like they used to be in Python 2.2 and before);
you must keep a reference to the return value of \function{intern()}
around to benefit from it]{2.3}
\end{funcdesc}
\begin{datadesc}{last_type}
\dataline{last_value}
\dataline{last_traceback}