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

Skip to content

gh-118527: Intern filename, name, and qualname in code objects. #118558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2024

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented May 3, 2024

This interns the strings for co_filename, co_name, and co_qualname on codeobjects in the free-threaded build. This partially addresses a reference counting bottleneck when creating closures concurrently. The functions take the name and qualified name from the code object.

This interns the strings for `co_filename`, `co_name`, and `co_qualname`
on codeobjects in the free-threaded build. This partially addresses a
reference counting bottleneck when creating closures concurrently. The
functions take the name and qualified name from the code object.
@colesbury
Copy link
Contributor Author

I think it would also be reasonable to internalize these strings in the default build, but I went with the more conservative option of limiting it to Py_GIL_DISABLED builds for now.

Copy link
Contributor

@DinoV DinoV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intern all the things!

@colesbury colesbury merged commit 37c31be into python:main May 3, 2024
39 checks passed
@colesbury colesbury deleted the gh-118527-code-names branch May 3, 2024 22:16
@brandtbucher
Copy link
Member

brandtbucher commented May 4, 2024

I think this made our generated files different for debug vs. non-debug normal vs free-threaded builds, since marshal serializes interned and non-interned strings differently.

SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
…python#118558)

This interns the strings for `co_filename`, `co_name`, and `co_qualname`
on codeobjects in the free-threaded build. This partially addresses a
reference counting bottleneck when creating closures concurrently. The
closures take the name and qualified name from the code object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants