Skip to content

ENH: Adopt _simd for multi-phase module initialization - #32335

Merged
mattip merged 2 commits into
numpy:mainfrom
prathamhole14:simd_multiphase_init
Sep 2, 2026
Merged

mattip merged 2 commits into
numpy:mainfrom
prathamhole14:simd_multiphase_init

Conversation

@prathamhole14

@prathamhole14 prathamhole14 commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

PR summary

As titled, please see #32451, I have followed this https://docs.python.org/3/c-api/extension-modules.html doc.

Related to: #29021

AI Disclosure

In re-reviewing the PR with claude opus 5 and writing comments.


static PyModuleDef_Slot _simd_slots[] = {
{Py_mod_exec, _simd_exec},
#if PY_VERSION_HEX >= 0x030c00f0 // Python 3.12+

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dead code, maybe in another PR all instances like this can be removed? Please let me know.

@prathamhole14
prathamhole14 marked this pull request as ready for review August 27, 2026 11:31
@prathamhole14

Copy link
Copy Markdown
Member Author

Failing tests are unrelated.

@mattip

mattip commented Aug 31, 2026

Copy link
Copy Markdown
Member

This will enable reloading the module. Since PySIMDVectorType is still a static variable initialized by PySIMDVectorType_Init, reloading will re-initialize it, causing a mess if anyone has a pointer to the old version. So this either needs to block reloading, like the module_loaded flag in _multiarray_umath, or to make that a heap type.

@prathamhole14

Copy link
Copy Markdown
Member Author

ah yes right! added module_loaded.

@mattip
mattip merged commit 2f8bc80 into numpy:main Sep 2, 2026
91 checks passed
@mattip

mattip commented Sep 2, 2026

Copy link
Copy Markdown
Member

Thanks @prathamhole14

@prathamhole14
prathamhole14 deleted the simd_multiphase_init branch September 2, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants