Skip to content

SubTracker: Convert static types (PyTypeObject) to heap types via PyType_FromModuleAndSpec #32747

Open

Description

@prathamhole14

Part of #32451 and #31913. This is intended to be a tracking issue for a series of PRs converting NumPy's static types to heap types.

NumPy currently defines its types (ndarray, dtype, ufunc, scalars, iterators, etc.) as static PyTypeObjects. Static types are shared by every interpreter in the process, including their tp_dict and reference counts, so they can't be isolated per interpreter. The CPython Isolating Extension Modules guide recommends replacing them with heap types created by PyType_FromModuleAndSpec.

This issue depends on multi-phase init (#29021) and generally follows the Changing Static Types to Heap Types section of the guide:

Converting to heap types is also a prerequisite for building against the Limited API, where static PyTypeObject definitions are not possible, see #31913.

Activity

  1. mattip commented on Sep 22, 2026

    @mattip
    Member

    @Abdellox this is part of a larger effort by @prathamhole14. Any extra help at this point would not be helpful.

  2. da-woods commented on Sep 23, 2026

    @da-woods
    Contributor

    Just a quick note that I have an existing PR to do this for f2py so no need to duplicate that.

    I suspect you weren't planning to cover f2py in this effort though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions