Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffi: Add definition for PyType_GetModuleByDef #3734

Merged
merged 1 commit into from Jan 13, 2024

Conversation

jadedpasta
Copy link
Contributor

This API is available starting in 3.11. It is not part of the Stable ABI.

PyType_GetModuleByDef searches the MRO of the given type for a module matching the given module spec. It can be useful for users use that pyo3_ffi directly and want to support multiple interpreters/per interpreter GIL. It is useful to obtain access to the module state from special methods like tp_new that can't use the METH_METHOD calling convention.

I am not sure how to check if this API is available on PyPy. If someone could give me a pointer to where to check, that would be great!

Copy link

codspeed-hq bot commented Jan 10, 2024

CodSpeed Performance Report

Merging #3734 will degrade performances by 10.44%

Comparing jadedpasta:ffi-pytype-getmodulebydef (83f0f22) with main (f8878a7)

🎉 Hooray! codspeed-rust just leveled up to 2.3.3!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

⚡ 1 improvements
❌ 2 regressions
✅ 75 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main jadedpasta:ffi-pytype-getmodulebydef Change
extract_str_downcast_fail 238.3 ns 266.1 ns -10.44%
extract_int_downcast_fail 238.3 ns 266.1 ns -10.44%
list_via_downcast 153.9 ns 126.1 ns +22.03%

Copy link
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 for the PR! One tiny adjustment regarding PyPy, and then this should be good to merge. Also please squash the commits, sadly with GitHub Merge Queue we can't do that automatically.

pyo3-ffi/src/cpython/object.rs Outdated Show resolved Hide resolved
This API is available starting in 3.11. It is not part of the Stable ABI.

PyType_GetModuleByDef searches the MRO of the given type for a module
matching the given module spec. It can be useful for users use that
`pyo3_ffi` directly and want to support multiple interpreters/per
interpreter GIL. It is useful to obtain access to the module state from
special methods like `tp_new` that can't use the METH_METHOD calling
convention.

This API is not supported on PyPy yet, but guess the symbol name for the future.
Copy link
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! 👍

@davidhewitt davidhewitt added this pull request to the merge queue Jan 13, 2024
Merged via the queue into PyO3:main with commit 48e74b7 Jan 13, 2024
37 of 38 checks passed
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.

None yet

2 participants