Skip to content

No std ThreadId - #6056

Open
Person-93 wants to merge 10 commits into
PyO3:mainfrom
Person-93:no_std_thread_id
Open

No std ThreadId#6056
Person-93 wants to merge 10 commits into
PyO3:mainfrom
Person-93:no_std_thread_id

Conversation

@Person-93

Copy link
Copy Markdown
Contributor

Re-implement ThreadId using PyThread_get_thread_ident. This makes is usable in no_std context.

@clin1234 clin1234 left a comment

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.

lgtm

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

Thanks, one comment on the FFI definition (see below).

Do you expect that the test suite (which does a lot of thread spawning) will need to change?

Comment thread pyo3-ffi/src/pythread.rs Outdated
@Person-93

Copy link
Copy Markdown
Contributor Author

Do you expect that the test suite (which does a lot of thread spawning) will need to change?

I don't think it will need to change, but it might be worth enabling it for wasm build and pulling in one of the wasm threading crates as a dev dependency.

@Person-93
Person-93 requested a review from davidhewitt May 22, 2026 16:37
Comment thread pyo3-ffi/src/pythread.rs Outdated
@Person-93
Person-93 force-pushed the no_std_thread_id branch 2 times, most recently from 2f2eb80 to 513cc78 Compare June 3, 2026 21:34
@Person-93
Person-93 requested a review from davidhewitt June 4, 2026 15:31

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

Thanks

@davidhewitt
davidhewitt added this pull request to the merge queue Jun 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 4, 2026
Comment thread pyo3-ffi/src/pythread.rs
@davidhewitt
davidhewitt enabled auto-merge June 9, 2026 08:41
@davidhewitt
davidhewitt added this pull request to the merge queue Jun 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 9, 2026
@codspeed-hq

codspeed-hq Bot commented Jun 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 141 untouched benchmarks
⏩ 6 skipped benchmarks1


Comparing Person-93:no_std_thread_id (5b9a18c) with main (a30ced8)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@clin1234

Copy link
Copy Markdown
Contributor

@codspeedbot explain why this is faster

@davidhewitt
davidhewitt added this pull request to the merge queue Jun 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 11, 2026
@davidhewitt
davidhewitt added this pull request to the merge queue Jun 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 12, 2026
@Person-93

Copy link
Copy Markdown
Contributor Author

Should we exclude PyPy from no_std support?

@Person-93
Person-93 marked this pull request as draft June 18, 2026 21:24
@Person-93

Copy link
Copy Markdown
Contributor Author

I don't think this will work for PyPy, that means we will need to use rust std's ThreadId when the std feature is enabled, so this is blocked on #6155

@Person-93
Person-93 marked this pull request as ready for review July 27, 2026 01:45
@Person-93
Person-93 force-pushed the no_std_thread_id branch 2 times, most recently from af0618c to cd7e9f5 Compare July 27, 2026 02:38
@davidhewitt

Copy link
Copy Markdown
Member

I lost this thread, what made us conclude this doesn't work for PyPy?

@Person-93

Copy link
Copy Markdown
Contributor Author

I lost this thread, what made us conclude this doesn't work for PyPy?

PyPy doesn't seem to have the function to get the thread id.

@davidhewitt

Copy link
Copy Markdown
Member

It looks like it should be present:

https://github.com/pypy/pypy/blob/808488746c6abf3961a131eb9215b5073853e123/pypy/module/cpyext/include/pythread.h#L18

I'll try to figure out where it's going wrong and if needed report an issue upstream.

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