Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3978d75

Browse files
committed
Added intern()
1 parent 38e2ec4 commit 3978d75

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,19 @@ \section{Built-in Functions}
212212
the backslash convention.
213213
\end{funcdesc}
214214

215+
\begin{funcdesc}{intern}{string}
216+
Enter \var{string} in the table of ``interned'' strings and return
217+
the interned string -- which is \var{string} itself or a copy.
218+
Interning strings is useful to gain a little performance on
219+
dictionary lookup -- if the keys in a dictionary are interned, and
220+
the lookup key is interned, the key comparisons (after hashing) can
221+
be done by a pointer compare instead of a string compare. Normally,
222+
the names used in Python programs are automatically interned, and
223+
the dictionaries used to hold module, class or instance attributes
224+
have interned keys. Interned strings are immortal (i.e. never get
225+
garbage collected).
226+
\end{funcdesc}
227+
215228
\begin{funcdesc}{int}{x}
216229
Convert a number to a plain integer. The argument may be a plain or
217230
long integer or a floating point number. Conversion of floating

Doc/libfuncs.tex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,19 @@ \section{Built-in Functions}
212212
the backslash convention.
213213
\end{funcdesc}
214214

215+
\begin{funcdesc}{intern}{string}
216+
Enter \var{string} in the table of ``interned'' strings and return
217+
the interned string -- which is \var{string} itself or a copy.
218+
Interning strings is useful to gain a little performance on
219+
dictionary lookup -- if the keys in a dictionary are interned, and
220+
the lookup key is interned, the key comparisons (after hashing) can
221+
be done by a pointer compare instead of a string compare. Normally,
222+
the names used in Python programs are automatically interned, and
223+
the dictionaries used to hold module, class or instance attributes
224+
have interned keys. Interned strings are immortal (i.e. never get
225+
garbage collected).
226+
\end{funcdesc}
227+
215228
\begin{funcdesc}{int}{x}
216229
Convert a number to a plain integer. The argument may be a plain or
217230
long integer or a floating point number. Conversion of floating

0 commit comments

Comments
 (0)