Repository navigation
ENH: Port numpy._core._simd to the Limited API - #32244
Conversation
Replace the constructs that are not part of the Limited API: the static PyTypeObject and its PySequenceMethods become a PyType_Spec heap type, PyObject_New() becomes PyType_GenericAlloc(), and the fast sequence, tuple and list accessors become their checked equivalents. Add the libc includes that Python.h stops providing at Py_LIMITED_API >= 3.11. Nearly all of the module's Python-facing code is compiled into the _simd_mtargets archive, which the `limited_api:` kwarg does not reach, so add py_limited_api_args and pass it there.
python.allow_limited_api defaults to false, so this is a no-op for shipped wheels.
5b12c74 to
fc49097
Compare
|
This PR is ready for review! |
mattip
left a comment
There was a problem hiding this comment.
Other than one simplification this looks good to me.
b04a3ae to
c0d261a
Compare
|
There is just this niggle left
I think this is a non-critical part of NumPy, so I don't want to push too hard on benchmarks, was there something in particular that might be problematic? |
Nope, I planned to do benchmark just to see if anything is affected. Not that I think anything will, since the diff doesn't necessarily make things slower. I did try benchmarking but all I was able to do is capture noise with no noticeable regression due to this diff. I think this is safe to go in terms of benchmarks. |
|
Cool. At some point we should refactor |
|
Done in this PR itself. |
|
Ahh, I merged #32335 and now there are merge conflicts |
|
Thanks @prathamhole14 |
PR summary
Related to: #31913
I will update this soon with benchmarks. For now I will look how CI reacts, locally all the tests are passing for python
3.13linux build with limted api flag on.AI Disclosure
In researching and brainstorming specially the meson build part and for writing comments.