Skip to content

gh-155358: Convert sys structseq types to heap types - #155368

Open
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:sys_types
Open

gh-155358: Convert sys structseq types to heap types#155368
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:sys_types

Conversation

@vstinner

@vstinner vstinner commented Aug 7, 2026

Copy link
Copy Markdown
Member

Convert the following structseq types from static (built-in) types to heap types:

  • AsyncGenHooksType
  • Hash_InfoType
  • WindowsVersionType
  • FlagsType
  • VersionInfoType

So these types are no longer shared between sub-interpreters.

Cleanup also the EmscriptenInfoType type.

Changes:

  • Replace _PyStructSequence_InitBuiltin() with PyStructSequence_NewType() or _PyStructSequence_NewType().
  • Add PyInterpreterState.sys_state structure.
  • Rename sys.get_asyncgen_hooks() type from "asyncgen_hooks" to "sys.asyncgen_hooks".
  • Add test.support.check_immutable_type().

Convert the following structseq types from static (built-in) types to
heap types:

* AsyncGenHooksType
* Hash_InfoType
* WindowsVersionType
* FlagsType
* VersionInfoType

So these types are no longer shared between sub-interpreters.

Cleanup also the EmscriptenInfoType type.

Changes:

* Replace _PyStructSequence_InitBuiltin() with
  PyStructSequence_NewType() or _PyStructSequence_NewType().
* Add PyInterpreterState.sys_state structure.
* Rename sys.get_asyncgen_hooks() type from "asyncgen_hooks" to
  "sys.asyncgen_hooks".
* Add test.support.check_immutable_type().
@vstinner

vstinner commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

If this change is merged, it would be interesting to convert the following 4 static types to heap types as well:

Objects/floatobject.c:    if (_PyStructSequence_InitBuiltin(interp, &FloatInfoType,
Objects/longobject.c:    if (_PyStructSequence_InitBuiltin(interp, &Int_InfoType,
Python/errors.c:    if (_PyStructSequence_InitBuiltin(interp, &UnraisableHookArgsType,
Python/thread.c:    if (_PyStructSequence_InitBuiltin(interp, &ThreadInfoType, &threadinfo_desc) < 0) {

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.

1 participant