FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-140544: store pointer to interpreter state as a thread local for fast access by kumaraditya303 · Pull Request #140573 · python/cpython · GitHub

/ cpython Public

gh-140544: store pointer to interpreter state as a thread local for fast access - #140573

Merged
kumaraditya303 merged 9 commits into
python:mainfrom
kumaraditya303:interp-tls
Oct 25, 2025
Merged

gh-140544: store pointer to interpreter state as a thread local for fast access#140573
kumaraditya303 merged 9 commits into
python:mainfrom
kumaraditya303:interp-tls

Conversation

kumaraditya303 commented Oct 25, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The core change looks good. Mostly nitpicks from me.

Comment thread Python/pystate.c Outdated
Comment thread Include/internal/pycore_pystate.h Outdated

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

kumaraditya303 merged commit ef4665f into python:main Oct 25, 2025
48 of 49 checks passed
kumaraditya303 deleted the interp-tls branch October 25, 2025 14:26
_Py_EnsureTstateNotNULL(tstate);
#endif
return tstate->interp;
#if !defined(Py_BUILD_CORE_MODULE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should this be

#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE)

instead?

When testing the current main against mypyc, I'm seeing a new error message

In file included from /.../mypy/mypyc/lib-rt/misc_ops.c:1137:
In file included from /.../cpython/Include/internal/pycore_object.h:12:
In file included from /.../cpython/Include/internal/pycore_gc.h:12:
/.../cpython/Include/internal/pycore_pystate.h:213:12: error: use of undeclared identifier '_Py_tss_interp'
    return _Py_tss_interp;
           ^
1 error generated.

Mypyc does use some of the internal headers. In particular

#define Py_BUILD_CORE
...
#include "internal/pycore_object.h"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess it is because mypyc doesn't define HAVE_THREAD_LOCAL which is defined when python is built, does #140623 fixes it for you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think we should just remove the check for HAVE_THREAD_LOCAL on line 92.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess it is because mypyc doesn't define HAVE_THREAD_LOCAL which is defined when python is built, does #140623 fixes it for you?

Yes, that works.

I think we should just remove the check for HAVE_THREAD_LOCAL on line 92.

Guess, this would work too.

StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL