Skip to content

Feature request: support dynamic_context with the sysmon measurement core #2150

Open

Description

@jab

Is your feature request related to a problem?

The sysmon measurement core (introduced in 7.9.0 and default on Python 3.14+) does not support dynamic_context. When e.g. dynamic_context = test_function is configured, coverage.py falls back to the ctrace core, forgoing the performance benefits of sys.monitoring.

For projects that use both branch = True and dynamic_context = test_function, the sysmon core is never used — even on Python 3.14+ where it's the default and where branch coverage is now supported.

Describe the solution you'd like

Support dynamic_context = test_function (and ideally other dynamic context strategies) when using the sysmon measurement core, so that projects using dynamic contexts can benefit from the lower overhead of sys.monitoring on Python 3.14+.

Additional context

Activity

  1. added
    enhancement
    on Mar 29, 2026
  2. nedbat commented on Mar 29, 2026

    @nedbat
    Member

    I'd like to find time to explore how much of the sys.monitoring benefit we could keep while using dynamic contexts. sys.monitoring avoids overhead by letting us disable events after they've been fired once. But dynamic contexts only work by continually examining the context, so we need to keep some events permanently enabled.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions