Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

C API: Add PyType_GetModuleByDef() to the limited C API version 3.13 #116936

Closed
Labels
@vstinner

Description

@vstinner

I propose addingPyType_GetModuleByDef() to the limited C API version 3.13. The function was added to Python 3.9, the function is now well tested. We could add it way earlier to the limited C API.

cc@encukou


ThePyType_GetModuleByDef() function is needed to access themodule state in C function which don't get a module as first parameter, but only an instance of a heap type. Heap types should be created withPyType_FromModuleAndSpec(module, spec, bases) to store the module in the type.PyType_GetModuleByDef(type) gives the module and thenPyModule_GetState() gives the moulde state.

Examples of functions which don't get amodule argument:

  • Class methods
  • Most slots, examples:tp_new,tp_richcompare,tp_iternext, etc.
  • PyGetSetDef getter and setter functions

WithoutPyType_GetModuleByDef(), many static types cannot be converted to heap types.

The following stdlib extensions usePyType_GetModuleByDef()

Modules/_asynciomodule.cModules/_bz2module.cModules/_collectionsmodule.cModules/_csv.cModules/_decimal/_decimal.cModules/_elementtree.cModules/_functoolsmodule.cModules/_io/_iomodule.hModules/_pickle.cModules/_queuemodule.cModules/_randommodule.cModules/_sqlite/module.hModules/_ssl.cModules/_ssl.hModules/_struct.cModules/_testmultiphase.cModules/_threadmodule.cModules/_xxinterpchannelsmodule.cModules/_zoneinfo.cModules/arraymodule.cModules/cjkcodecs/multibytecodec.cModules/clinic/_testmultiphase.c.hModules/itertoolsmodule.cModules/socketmodule.cPython/Python-tokenize.c

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp