Skip to content

Use Py_IS_TYPE on abi3 & python 3.15+#5977

Merged
bschoenmaeckers merged 2 commits intoPyO3:mainfrom
bschoenmaeckers:Py_IS_TYPE_ABI3
Apr 23, 2026
Merged

Use Py_IS_TYPE on abi3 & python 3.15+#5977
bschoenmaeckers merged 2 commits intoPyO3:mainfrom
bschoenmaeckers:Py_IS_TYPE_ABI3

Conversation

@bschoenmaeckers
Copy link
Copy Markdown
Member

Avoid raw pointer comparison on ABI3 when Py_IS_TYPE is available.

xref RustPython/RustPython#7562

@bschoenmaeckers bschoenmaeckers force-pushed the Py_IS_TYPE_ABI3 branch 2 times, most recently from eb1faa7 to 2cecf6d Compare April 16, 2026 07:32
Copy link
Copy Markdown
Contributor

@ngoldbaum ngoldbaum left a comment

Choose a reason for hiding this comment

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

This also follows how CPython spells these check macros.

I seriously doubt adding one extra function call that can be inlined matters for non-limited API builds, but I'll defer to @davidhewitt to give this a look and hit the merge button.

@bschoenmaeckers
Copy link
Copy Markdown
Member Author

@davidhewitt Any concerns?

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.

Definitely an improvement and matches CPython better too 🎉

Comment thread newsfragments/5977.changed.md Outdated
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.

I would probably drop the newsfragment, seems like ultimately this is a refactoring that doesn't have external effect (yet)?

@bschoenmaeckers
Copy link
Copy Markdown
Member Author

Thanks!

@bschoenmaeckers bschoenmaeckers added the CI-skip-changelog Skip checking changelog entry label Apr 23, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 23, 2026

Merging this PR will not alter performance

✅ 105 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing bschoenmaeckers:Py_IS_TYPE_ABI3 (f4cd954) with main (c24a951)

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.

@bschoenmaeckers bschoenmaeckers added this pull request to the merge queue Apr 23, 2026
Merged via the queue into PyO3:main with commit 9677e50 Apr 23, 2026
42 of 45 checks passed
@bschoenmaeckers bschoenmaeckers deleted the Py_IS_TYPE_ABI3 branch April 23, 2026 19:04
davidhewitt pushed a commit to davidhewitt/pyo3 that referenced this pull request May 1, 2026
* Use `Py_IS_TYPE` on abi3 & python 3.15+

* Delete changelog
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.

4 participants