-
Notifications
You must be signed in to change notification settings - Fork 778
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
Deprecate / remove _Py
internal APIs from pyo3-ffi
#3762
Comments
So, excluding
|
I had a proposal for a "strncpy"-style function1 that would copy the bits of a Python integer into normal memory (or fail if you don't provide a big enough buffer). The nice thing about it is we could have an (unstable) inline version that can do fast copies for small ints, and be an optimal single API for all conversions, but I suspect even a DLL-exported version would still be as good as the range of functions we currently have. Is that a design that would work well for PyO3? Or do you prefer to request the bit length, then allocate, then copy? Footnotes
|
@zooba I think that proposed API could work fine! We could use stack space for small ints, which could let us just make the one FFI call and skip allocation if it's small enough to succeed first try. (I think the Whether you prefer to propose a new API or stabilise the existing APIs, I think we can make it work in PyO3 👍 |
It was discussed python/cpython#111140 No clear API was proposed. |
I see that the integer-to-bytes conversions have now been added in python/cpython#114886, thanks @zooba @encukou and all who worked to get that done! We'll be sure to switch for 3.13 👍 |
@davidhewitt Do give a shout if you find it awkward in any way. We've still got time and freedom to make changes, and your case is very much the intended case, so we want it to work well (though I'm hoping we'll get some of our own improvements by using it internally too). |
The main outcome I got from my stream today was that @encukou and @vstinner (and presumably the rest of the Core Devs) want to regard CPython C API symbols prefixed with
_Py
as internal APIs which don't carry any version stability (not even necessarily in the same Python minor version patch series).I think this means that we should consider removing all such definitions with this
_Py
prefix frompyo3-ffi
, or at the very least making users think very hard before they choose to use these, if there's a good reason for any of these to be exposed in PyO3.I took some notes on stream about where we use these definitions in PyO3 itself, they're on my desktop PC along with a small patch which removes use of a couple, I'll aim to push both tomorrow.
The text was updated successfully, but these errors were encountered: