Skip to content

Add offsets for dict introspection to _Py_DebugOffsets #146462

@charles-dyfis-net

Description

@charles-dyfis-net

Feature or enhancement

Proposal:

To use _Py_DebugOffsets to perform version-independent read-only introspection of a Python process, struct offsets are required that aren't currently exposed:

  • tp_dictoffset -- where the dict pointer lives
  • tp_basicsize -- where inline values start
  • ht_cached_keys -- key ordering for inline values in heap types

The immediately motivating use case is implementing py-spy (read-only sampling profiler) support for Python 3.14 without continuing the prior practice of shipping bindgen wrappers for each supported version; dict introspection is required to read thread names from threading._active[tid]._name (which also requires looking through sys.modules to find the threading module), and for implementing --dump-locals.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions