This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mpage
Recipients carljm, dino.viehland, itamaro, mpage
Date 2022-03-01.22:20:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646173258.53.0.415525425157.issue46898@roundup.psfhosted.org>
In-reply-to
Content
CPython extensions providing optimized execution of Python bytecode (e.g. the Cinder JIT) may need to hook into the lifecycle of code objects to determine what to optimize or to free resources allocated for code objects that no longer exist. We propose adding an API to allow extensions to set callbacks that will be invoked whenever code objects are created or destroyed.

Proposed API:

```
typedef enum {
  PYCODE_LCEVT_CREATED,
  PYCODE_LCEVT_DESTROYED
} PyCode_LifecycleEvent;

// A callback to be called when a code object is created or about to be destroyed.
typedef void(*PyCode_LifecycleCallback)(
  PyCode_LifecycleEvent event,
  PyCodeObject* code);

void PyCode_SetLifecycleCallback(PyCode_LifecycleCallback callback);
PyCode_LifecycleCallback PyCode_GetLifecycleCallback();

```
History
Date User Action Args
2022-03-01 22:20:59mpagesetrecipients: + mpage, carljm, dino.viehland, itamaro
2022-03-01 22:20:58mpagesetmessageid: <1646173258.53.0.415525425157.issue46898@roundup.psfhosted.org>
2022-03-01 22:20:58mpagelinkissue46898 messages
2022-03-01 22:20:58mpagecreate