-
Notifications
You must be signed in to change notification settings - Fork 48
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
Adds support for Py_LIMITED_API #14
base: master
Are you sure you want to change the base?
Conversation
There was one issue with Container._generate_container_constructor that lead to segfault with limited API for some reason. Not sure what that was about exactly (any ideas?) but since it seems to work fine with the second option of iterative copy, I just put it behind a condition. |
This is a pretty cool feature to have. Thanks! However I don't like one thing about this approach: too many ifdefs, too many code paths. I am perfectly happy to make the "limited API" way of doing things the default (as long as it also works in Python 2.7). I am not so happy with the ifdefs. I would prefer to use ifdef in only in case it's not possible to support something with limited api and you have to disable that code in that case. For the cases where a feature can work with and without limited api, can you find a way that makes it work with both without ifdefs? For example:
Can this simply become |
Hi Gustavo, thanks for looking into it. I was thinking the same about the ifdefs and added PBG_SETATTR macro to get around those with tp_dict but hadn't used it yet. Do you think it would be ok to merge the limited API feature in stages? I'm just doubting I'd have time/knowledge to test all of the language features for corner cases where bindings maybe generated that doesn't compile with Py_LIMITED_API. |
Scratch that about PyObject_DEL, I had |
Here's changes that were required to generate PEP384 compliant code (#13) for my use-case. It's likely missing various bits and pieces to be a complete implementation though.
Initially I considered adding an option to pybindgen that generates either stable API or traditional code, but in the end it made more sense to do it with preprocessor conditions. This does add a bit of length to the C output.
Didn't look into any new tests yet,
tests/wscript
ran successfully but not with-DPy_LIMITED_API
for the moment.