Skip to content

Commit 2381777

Browse files
committed
Add notes to sys.intern and PyUnicode_InternInPlace about immortal strings
1 parent c07f6d6 commit 2381777

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Doc/c-api/unicode.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,8 @@ They all return ``NULL`` or ``-1`` if an exception occurs.
17531753
Note that interned strings are not “immortal”.
17541754
You must keep a reference to the result to benefit from interning.
17551755
1756+
.. note::
1757+
In the free-threaded build, all interned strings are :term:`immortal`.
17561758
17571759
.. c:function:: PyObject* PyUnicode_InternFromString(const char *str)
17581760

Doc/library/sys.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,9 @@ always available. Unless explicitly noted otherwise, all variables are read-only
13251325
Interned strings are not :term:`immortal`; you must keep a reference to the
13261326
return value of :func:`intern` around to benefit from it.
13271327

1328+
.. note::
1329+
1330+
In the free-threaded build, all interned strings are :term:`immortal`.
13281331

13291332
.. function:: _is_gil_enabled()
13301333

0 commit comments

Comments
 (0)