Skip to content

Do not use static type references when compiling for RustPython#5995

Merged
bschoenmaeckers merged 7 commits into
PyO3:mainfrom
bschoenmaeckers:RustPython-type-statics
May 9, 2026
Merged

Do not use static type references when compiling for RustPython#5995
bschoenmaeckers merged 7 commits into
PyO3:mainfrom
bschoenmaeckers:RustPython-type-statics

Conversation

@bschoenmaeckers
Copy link
Copy Markdown
Member

@bschoenmaeckers bschoenmaeckers commented Apr 23, 2026

Removed all usage of static type pointers when compiling for RustPython. Diff is large but is very repetitive.

Test plan

~/repo/pyo3 ❱ RUSTFLAGS="--cfg RustPython" cargo check
    Blocking waiting for file lock on build directory
    Checking pyo3-ffi v0.28.3 (/Users/basschoenmaeckers/repo/pyo3/pyo3-ffi)
    Checking pyo3 v0.28.3 (/Users/basschoenmaeckers/repo/pyo3)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.38s

xref RustPython/RustPython#7562

https://discuss.python.org/t/c-api-add-py-getbuildintype-and-py-getbuildintypeborrowed/107010

@bschoenmaeckers bschoenmaeckers force-pushed the RustPython-type-statics branch from 87e669a to 391626b Compare April 24, 2026 12:53
@bschoenmaeckers bschoenmaeckers added the CI-skip-changelog Skip checking changelog entry label Apr 24, 2026
@bschoenmaeckers bschoenmaeckers force-pushed the RustPython-type-statics branch from 391626b to 583b78d Compare April 24, 2026 13:27
@bschoenmaeckers bschoenmaeckers marked this pull request as ready for review April 24, 2026 13:30
@bschoenmaeckers bschoenmaeckers force-pushed the RustPython-type-statics branch 4 times, most recently from 91658f1 to a136b15 Compare April 30, 2026 07:46
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 30, 2026

Merging this PR will not alter performance

✅ 105 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing bschoenmaeckers:RustPython-type-statics (bcbd085) with main (20246a8)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

Comment thread pyo3-ffi/src/boolobject.rs Outdated
Comment on lines 15 to 17
}

extern_libpython! {
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.

There are a number of places in this PR where the extern blocks can be merged with one immediately above / below.

(I wonder if we could / should write a lint for that, maybe as part of the recently added machinery in the noxfile for formatting these?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've merged most adjacent blocks where the cfg attributes where the same. Please let me know I you see an other spot that needs cleaning.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've moved around some some locally implemented/exported functions around to reduce even more extern_libpython blocks. Please let me know what you think.

@bschoenmaeckers bschoenmaeckers mentioned this pull request Apr 30, 2026
Merge adjacent extern blocks

Fixes
@bschoenmaeckers bschoenmaeckers force-pushed the RustPython-type-statics branch from e8b2d31 to 05475d1 Compare May 6, 2026 11:11
@bschoenmaeckers bschoenmaeckers force-pushed the RustPython-type-statics branch from 98f5fab to 7a5445f Compare May 6, 2026 11:37
@bschoenmaeckers bschoenmaeckers force-pushed the RustPython-type-statics branch from e57a4d3 to 2582a79 Compare May 6, 2026 13:05
@bschoenmaeckers
Copy link
Copy Markdown
Member Author

I've also fixed all the places where link_name was not properly gated to PyPy only.

Copy link
Copy Markdown
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks, this seems reasonable to me

@bschoenmaeckers bschoenmaeckers added this pull request to the merge queue May 9, 2026
@bschoenmaeckers
Copy link
Copy Markdown
Member Author

Thanks for reviewing this!

Merged via the queue into PyO3:main with commit eef6277 May 9, 2026
45 of 46 checks passed
@bschoenmaeckers bschoenmaeckers deleted the RustPython-type-statics branch May 9, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI-skip-changelog Skip checking changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants