pantab icon indicating copy to clipboard operation
pantab copied to clipboard

Use Py_Limited_API Flag for Builds

Open WillAyd opened this issue 5 years ago • 4 comments

I think we are only using functions that are guaranteed to have a stable ABI in the Python 3.X series, so we could likely build with this setting to reduce the amount of wheels we need to generate

This is set in setup.py roughly using macros = [("Py_LIMITED_API", "1”)]

WillAyd avatar Nov 02 '20 23:11 WillAyd

Note that PyTupleObject which we use in pantab.c is not part of the limited API...

vogelsgesang avatar Feb 09 '21 00:02 vogelsgesang

Yea that is fortunately easy enough to swap out with PyObject, but when trying this a while back I found out that PyUnicode_* methods are not part of the stable ABI, which would make this difficult to achieve in its current form

There is a PEP to enhance and better document the stable ABI which could help here. This would require some further investigation and might not be possible for a bit, but open to whatever anyone can find. It would be nice to not have to distribute individual wheels for each Py3.X version

WillAyd avatar Feb 09 '21 01:02 WillAyd

Looks like PyUnicode_AsUTF8AndSize was added to the limited API in Python 3.10, so can provide limited wheels at least from that version forward.

Older versions may have the ability to just use PyUnicode_AsUTF8 though would take a refactor of code and some research

WillAyd avatar Dec 08 '21 18:12 WillAyd

Actually with nanobind we would need to wait until Python 3.12 becomes the minimum. Here is an example project:

https://github.com/wjakob/nanobind_example

So still a few years out

WillAyd avatar Jan 28 '24 01:01 WillAyd