charles-dyfis-net · GitHub

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

Linked PRs

Read the original on github.com ↗