Skip to content

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

Open
bschoenmaeckers wants to merge 2 commits intoPyO3:mainfrom
bschoenmaeckers:RustPython-type-statics
Open

Do not use static type references when compiling for RustPython#5995
bschoenmaeckers wants to merge 2 commits intoPyO3: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 3 times, most recently from 655b9a3 to 91658f1 Compare April 29, 2026 08:15
@bschoenmaeckers bschoenmaeckers force-pushed the RustPython-type-statics branch 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 improve performance by 13.8%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 104 untouched benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Benchmark BASE HEAD Efficiency
bench_pyclass_create 4.6 µs 4 µs +13.8%

Comparing bschoenmaeckers:RustPython-type-statics (e8b2d31) with main (8a00673)

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.

@bschoenmaeckers bschoenmaeckers mentioned this pull request Apr 30, 2026
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