New submission from Matt Page <mp...@cs.stanford.edu>:
CPython extensions providing optimized execution of Python bytecode (e.g. the Cinder JIT), or even CPython itself (e.g. the faster-cpython project) may wish to cache access to lookups in the class hierarchy (e.g. when resolving the target of a method call). Extensions that perform these optimizations need to know when to invalidate the cached values. CPython already has a mechanism to invalidate its internal state (e.g. the global method cache) when a type is modified: _PyType_Modified. We propose adding an API to allow extensions to set a callback that will be invoked by _PyType_Modified whenever a type, or any ancestor of the type in the class hierarchy, changes. Proposed API: ``` // A callback to be invoked with the modified type and optionally the name of // the attribute that was modified. typedef void(*PyType_ModifiedCallback)(PyTypeObject* type, PyObject* attr); // Set or get the callback. The callback may be cleared by supplying a NULL callback. void PyType_SetModifiedCallback(PyType_ModifiedCallback callback); PyType_ModifiedCallback PyType_GetModifiedCallback(); ``` ---------- components: C API, Interpreter Core messages: 414305 nosy: carljm, dino.viehland, itamaro, mpage priority: normal severity: normal status: open title: Type-Modified Callbacks type: enhancement _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46895> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com