GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add API to allow extensions to set callback function on creation and destruction of PyCodeObject · Issue #91054 · python/cpython

Add API to allow extensions to set callback function on creation and destruction of PyCodeObject #91054

New issue
Copy link
New issue
Copy link
Closed
Closed
Add API to allow extensions to set callback function on creation and destruction of PyCodeObject#91054
Copy link
Labels
3.12only security fixesonly security fixestopic-C-APItype-featureA feature request or enhancementA feature request or enhancement

Description

mpage
mannequin
opened on Mar 1, 2022
Issue body actions
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

Activity

  1. mpage commented on Mar 1, 2022

    @mpage
    mpagemannequin
    on Mar 1, 2022
    MannequinAuthor
    More actions

    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();
    
    
  2. mpage
    added
    3.11only security fixesonly security fixes
    topic-C-API
    type-featureA feature request or enhancementA feature request or enhancement
    on Mar 1, 2022
  3. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  4. gvanrossum commented on Sep 15, 2022

    @gvanrossum
    gvanrossum
    on Sep 15, 2022
    Member
    More actions

    In which header file would you put that? Maybe this is simple enough that you should just submit a PR?

  5. itamaro commented on Sep 15, 2022

    @itamaro
    itamaro
    on Sep 15, 2022
    Contributor
    More actions

    In which header file would you put that?

    would Include/cpython/code.h make sense for this API?

    Maybe this is simple enough that you should just submit a PR?

    hopefully yes, we intend to do that for 3.12.
    does the proposed API look reasonable?

  6. gvanrossum
    added
    3.12only security fixesonly security fixes
    and removed
    3.11only security fixesonly security fixes
    on Sep 24, 2022
  7. gvanrossum commented on Sep 24, 2022

    @gvanrossum
    gvanrossum
    on Sep 24, 2022
    Member
    More actions

    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 with PY_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.

    Reacted by Itamar Oren and Carl Meyer
  8. itamaro
    added 4 commits that reference this issue on Nov 23, 2022

    pythongh-91054: Add API to allow extensions to set callback function …

    f30e512

    pythongh-91054: Add API to allow extensions to set callback function …

    ccf51d6

    pythongh-91054: Add API to allow extensions to set callback function …

    3b871f8

    pythongh-91054: Add API to allow extensions to set callback function …

    2475ce4
  9. markshannon
    added a commit that references this issue on Dec 2, 2022

    GH-91054: Add code object watchers API (GH-99859)

    3c137dc
  10. pablogsal
    added a commit that references this issue on Dec 3, 2022

    Revert "GH-91054: Add code object watchers API (GH-99859)"

    9cf2109
  11. pablogsal commented on Dec 3, 2022

    @pablogsal
    pablogsal
    on Dec 3, 2022
    Member
    More actions

    Unfotunately, there are many buildbots failing to build this PR. Check buildbot.python.org/all/#/release_status for reference

    As per our buildbot policy, this PR will be reverted if the buildbot fleet is not fixed in the next 24h. @markshannon @itamaro can you please take a look?

    I have opened #99976. I will close it if the issue is fixed before the deadline.

  12. itamaro
    added a commit that references this issue on Dec 3, 2022

    pythonGH-91054: Reset static events counts in code watchers tests

    5a53c06
  13. pablogsal
    added a commit that references this issue on Dec 4, 2022

    GH-91054: Reset static events counts in code watchers tests (#99978)

    1012dc1
  14. itamaro commented on Dec 4, 2022

    @itamaro
    itamaro
    on Dec 4, 2022
    Contributor
    More actions

    this issue can be closed now!

  15. pablogsal
    closed this as completedon Dec 4, 2022
  16. carljm
    added 3 commits that reference this issue on Aug 9, 2023

    pythongh-91054: make code watcher tests resilient to other watchers

    f32672c

    pythongh-91054: make code watcher tests resilient to other watchers

    b40b696

    gh-91054: make code watcher tests resilient to other watchers (#107821)

    2ec16fe
  17. miss-islington
    added a commit that references this issue on Aug 10, 2023

    pythongh-91054: make code watcher tests resilient to other watchers (p…

    f53bd4d
  18. Yhg1s
    added a commit that references this issue on Aug 11, 2023

    [3.12] gh-91054: make code watcher tests resilient to other watchers (G…

    98dd9d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesonly security fixestopic-C-APItype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.