ENH: Implement per-module state for lapack_lite to avoid global static states#31928
ENH: Implement per-module state for lapack_lite to avoid global static states#31928prathamhole14 wants to merge 2 commits into
Conversation
|
Please ensure everything passes locally before making a PR. Running CI isn't free; and the maintainers get a notification for each commit regardless of whether it's a draft. Also; AI disclosure |
|
Sorry I should have provided context from the start, I did compile and ran tests locally and they passed but since this PR tries to adopt to limited api I was afraid that it might fail on other systems. This PR is related to #31913. |
|
Ah actually the CI failure isn't your fault; see #31932 |
| lapack_lite_exec(PyObject *m) | ||
| lapack_lite_traverse(PyObject *m, visitproc visit, void *arg) | ||
| { | ||
| lapack_lite_state *state = (lapack_lite_state *)PyModule_GetState(m); |
There was a problem hiding this comment.
I did not use get_lapack_lite_state since state here can actually be NULL unlike in check_object
|
Out of curiosity, why is this needed? I don't think per-module state is needed for limited API support. Or are you also working on subinterpreter support? |
|
That would be my "fault".Yes, the goal of the internship is both tasks, as a modernization of the internal NumPy code base,and to see if these types of changes affect performance. |
Yes it's not "requirement" for limited api but since CPython is moving towards subinterpreters, @mattip and I discussed to start this effort with moving to per-module state. |
I ran the benchmarks ( |
|
My basic (untested) intuition about performance is that looking things up in the module state will almost certainly be slower than looking things up from a static global. But in this case it's only an exception that will almost never be used so it shouldn't make a huge difference |
902a8e8 to
070942a
Compare
|
|
||
| #ifdef HAVE_BLAS_ILP64 | ||
| PyDict_SetItemString(d, "_ilp64", Py_True); | ||
| if (PyModule_AddObjectRef(m, "_ilp64", Py_True) < 0) { |
PR summary
Related to: #31930
AI Disclosure
Only for some research and improving comments.