-
Notifications
You must be signed in to change notification settings - Fork 779
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 module cleanup #1289
Comments
I've started implementing this, and ran into a couple of questions:
|
@nw0 thanks so much for being willing to help us out! In response to your questions:
P.S. I can imagine that this whole ffi cleanup will be quite a big PR. For ease of reviewing, and maybe also so that I and others can join in with the cleanup effort, I would suggest you open PRs with just a few files in it at a time; that way we can merge things as we go. Again, thank you so much! ❤️ |
A number of the comments read:
Line 143 in 3f093d9
As we don't support Python 3.5 any longer (let alone 3.3), shall I remove those? Asking as I'm not sure what it means. |
I was thinking of removing those comments and appreciate your help. 👍🏼 |
I've been exploring the code under I noticed that sometimes the My question is, what's the thought process behind what should and shouldn't be added to the FFI? I'm mostly confused by the |
Great question. In general we need to include all the The code in |
Thanks! I guess implementing the |
Sounds great! If you're looking for examples to refer back to, this series of PRs by @nw0 which has been some prior work in this area are excellent: https://github.com/PyO3/pyo3/pulls?q=is%3Apr+author%3Anw0+is%3Aclosed |
Still exploring the FFI code slowly. I have a few more questions. Would appreciate some pointers.
|
So in general all of these
The functions you note in your second example are actually still
Precisely - function pointers in C are nullable, however Rust's |
Here is something I wish I knew when I first started here and hope sharing here will help new contributor start more easily.
nm -D $PYPY_INSTALL_BASE/lib/libpypy3-c.so | grep PyDict_New
# 00000000018ef450 T PyPyDict_New extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyDict_New")]
pub fn PyDict_New() -> *mut PyObject;
}
|
I don't have time to make a PR right now, but wanted to note that last week some of the header files have moved in CPython again. There are a few changes, but this one in particular makes some definitions "internal-only": python/cpython#28957 |
The modules in
src/ffi
have become a bit out-of-date, and also quite disorganised so it's kinda hard to figure out what's missing.Since Python 3.9 the cpython include files have been split so that (roughly) the limited api is in
cpython/Include/
and the unlimited api is incpython/Include/cpython/
. I propose for simplicity in maintaining thepyo3::ffi
module we should reorganise code to match that structure.I suggest that we do the following things:
ffi/mod.rs
to be alphabetical and have// skipped foo.h
comments for each header present in cpython master which is not present in our bindings at the moment.ffi/cpython/mod.rs
to contain the unlimited api headers, and do the same as withffi/mod.rs
.ffi/
, reorganise the definitions in it appropriately intoffi
andffi/cpython
parts which match the cpython master definitions. This should include:// skipped foo
for each definitionfoo
we don't currently have in our definitions.The idea with each
// skipped foo
being in alphabetical order is that it's then hopefully easier for us to compare against upstream in the future.With the new
cpython
folder for the unlimited api, it might be reduce a lot of#[cfg(Py_LIMITED_API)]
chatter as we'll only need that once on themod cpython
definition.Also, it could be interesting to not have
pub use self::cpython::*
inffi/mod.rs
, so that users are forced to use unlimited api symbols asffi::cpython::foo
. But that's probably quite breaking, so I can go either way on it.Perhaps in general the above guidelines of how to organise our ffi modules should go in CONTRIBUTING.md ?
The text was updated successfully, but these errors were encountered: