mirror of
https://github.com/python/cpython.git
synced 2025-12-05 00:52:25 +00:00
Added intern()
This commit is contained in:
parent
38e2ec4f14
commit
3978d75cca
2 changed files with 26 additions and 0 deletions
|
|
@ -212,6 +212,19 @@ module from which it is called).
|
||||||
the backslash convention.
|
the backslash convention.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
|
\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. Interned strings are immortal (i.e. never get
|
||||||
|
garbage collected).
|
||||||
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{int}{x}
|
\begin{funcdesc}{int}{x}
|
||||||
Convert a number to a plain integer. The argument may be a plain or
|
Convert a number to a plain integer. The argument may be a plain or
|
||||||
long integer or a floating point number. Conversion of floating
|
long integer or a floating point number. Conversion of floating
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,19 @@ module from which it is called).
|
||||||
the backslash convention.
|
the backslash convention.
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
|
\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. Interned strings are immortal (i.e. never get
|
||||||
|
garbage collected).
|
||||||
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{int}{x}
|
\begin{funcdesc}{int}{x}
|
||||||
Convert a number to a plain integer. The argument may be a plain or
|
Convert a number to a plain integer. The argument may be a plain or
|
||||||
long integer or a floating point number. Conversion of floating
|
long integer or a floating point number. Conversion of floating
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue