Repository navigation
gh-144161: Clarify immortality of interned strings - #159701
Open
bearomorphism wants to merge 1 commit into
Open
bearomorphism wants to merge 1 commit into
bearomorphism wants to merge 1 commit into
Conversation
Clarify build-dependent interning behavior in the Python and C APIs and the free-threading HOWTO. Follow the discussion and earlier work in pythongh-144176 while retaining the advice to keep a reference to the result. Co-authored-by: Hernani Samuel Diniz <[email protected]>
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #144161.
The
sys.intern()andPyUnicode_InternInPlace()documentation currently says that interned strings are not immortal, while the free-threading HOWTO says that they are. Clarify that interned strings are not necessarily immortal and that the current free-threaded build makes all interned strings immortal.Keep the advice to retain a reference to the result, and describe free-threaded immortality as an implementation detail that may change. Also clarify that the HOWTO describes additional immortalization relative to the default build, rather than implying immortality is exclusive to free-threaded Python.
This follows the discussion and earlier work in #144176, whose author explicitly invited others to pick it up. Credit to Hernani Samuel Diniz for that patch. The new wording incorporates the review feedback and uses the current
free-threaded buildglossary term.Validation
make -C Doc html JOBS=4passed with warnings treated as errors; inspected the rendered sections and links.pre-commit run --files Doc/library/sys.rst Doc/c-api/unicode.rst Doc/howto/free-threading-python.rstpassed all applicable hooks.git diff --checkpassed before committing.-X gil=1. A dynamically created interned string was mortal in the regular build and immortal in the free-threaded build; the interned empty string was immortal in both.Documentation only; no runtime changes or NEWS entry.
AI assistance was used to investigate the behavior, draft the documentation, and run validation.
Co-authored-by: Hernani Samuel Diniz [email protected]