Skip to content

gh-146219: Document reusing a thread state across repeated foreign-thread calls#146221

Open
gpshead wants to merge 3 commits into
python:mainfrom
gpshead:gpshead/docs/gilstate-reentrant-performance
Open

gh-146219: Document reusing a thread state across repeated foreign-thread calls#146221
gpshead wants to merge 3 commits into
python:mainfrom
gpshead:gpshead/docs/gilstate-reentrant-performance

Conversation

@gpshead

@gpshead gpshead commented Mar 20, 2026

Copy link
Copy Markdown
Member

Add a subsection under "Non-Python created threads" explaining the performance cost of creating/destroying a PyThreadState on every Ensure/Release cycle and showing how to keep one alive for the thread's lifetime instead.

(read them & see the issue for more details)


📚 Documentation preview 📚: https://cpython-previews--146221.org.readthedocs.build/

@vstinner

Copy link
Copy Markdown
Member

cc @ZeroIntensity

Comment thread Doc/c-api/threads.rst Outdated
Comment thread Doc/c-api/threads.rst Outdated
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 8, 2026
@vstinner

Copy link
Copy Markdown
Member

PEP 788 API has been merged in Python 3.15: https://docs.python.org/dev/c-api/interp-lifecycle.html#cautions-regarding-runtime-finalization. The PR may need to be updated to refer to these APIs.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 18, 2026
gpshead added 2 commits June 29, 2026 03:23
Add a subsection under "Non-Python created threads" explaining the
performance cost of creating/destroying a PyThreadState on every
Ensure/Release cycle and showing how to keep one alive for the
thread's lifetime instead.
@gpshead gpshead force-pushed the gpshead/docs/gilstate-reentrant-performance branch from 9d7365d to 7fe5619 Compare June 29, 2026 03:26
@gpshead

gpshead commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

updated, please take another look.

@gpshead gpshead self-assigned this Jun 29, 2026
@gpshead gpshead added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 29, 2026
@read-the-docs-community

read-the-docs-community Bot commented Jun 29, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33361485 | 📁 Comparing a57095c against main (7d128e3)

  🔍 Preview build  

8 files changed · ± 8 modified

± Modified

@ZeroIntensity 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.

LGTM, with one minor typo.

Comment thread Doc/c-api/threads.rst Outdated
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir needs backport to 3.15 pre-release feature fixes, bugs and security fixes performance Performance or resource usage skip news topic-free-threading

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants