-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.12only security fixesonly security fixestopic-C-APItype-featureA feature request or enhancementA feature request or enhancement
Description
BPO | 46898 |
---|---|
Nosy | @carljm, @DinoV, @itamaro, @mpage |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2022-03-01.22:20:58.520>
labels = ['expert-C-API', 'type-feature', '3.11']
title = 'Add API to allow extensions to set callback function on creation and destruction of PyCodeObject'
updated_at = <Date 2022-03-01.22:20:58.520>
user = 'https://github.com/mpage'
bugs.python.org fields:
activity = <Date 2022-03-01.22:20:58.520>
actor = 'mpage'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['C API']
creation = <Date 2022-03-01.22:20:58.520>
creator = 'mpage'
dependencies = []
files = []
hgrepos = []
issue_num = 46898
keywords = []
message_count = 1.0
messages = ['414309']
nosy_count = 4.0
nosy_names = ['carljm', 'dino.viehland', 'itamaro', 'mpage']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue46898'
versions = ['Python 3.11']
Linked PRs
- gh-91054: Add code object watchers API #99859
- gh-91054: Revert "gh-91054: Add code object watchers API" #99976
- GH-91054: Reset static events counts in code watchers tests #99978
- gh-91054: make code watcher tests resilient to other watchers #107821
- [3.12] gh-91054: make code watcher tests resilient to other watchers (GH-107821) #107835
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixestopic-C-APItype-featureA feature request or enhancementA feature request or enhancement
Projects
Milestone
Relationships
Development
Select code repository
Activity
mpage commentedon Mar 1, 2022
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:
gvanrossum commentedon Sep 15, 2022
In which header file would you put that? Maybe this is simple enough that you should just submit a PR?
itamaro commentedon Sep 15, 2022
would
Include/cpython/code.h
make sense for this API?hopefully yes, we intend to do that for 3.12.
does the proposed API look reasonable?
gvanrossum commentedon Sep 24, 2022
The API looks reasonable -- I'd spell
LifeCycle
with two capital letters (though Wikipedia seems divided on this), and I'd start the enum values withPY_CODE
, similar to_PyCodeLocationInfoKind
in the same file. The implementation would seem straightforward, and code objects aren't created or destroyed at a monstrous rate (it might be worth seeing if this slows down unmarshalling noticeably, but I doubt it). The callback should probably be stored in the per-interpreter state.pythongh-91054: Add API to allow extensions to set callback function …
21 remaining items