Skip to content

Remove lazy dictionary tracking #127010

Description

@markshannon

Feature or enhancement

Proposal:

In order to reduce the overhead of cycle GC detection for objects that cannot be part of cycles, we lazily untrack tuples and dictionary that only refer to objects that cannot be part of a cycle.

This is fine for tuples, but dictionaries are mutable, so we need to check every time a dictionary is modified whether it needs to be tracked.

Since most objects no longer have a __dict__ dictionary, the complexity and overhead of this lazy tracking is not worth the small benefit in the cycle GC.

This was originally implemented in #126502, but is largely orthogonal to the main purpose of that PR, so should be implemented separately.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added
    type-featureA feature request or enhancement
    performancePerformance or resource usage
    3.14bugs and security fixes
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    and removed
    type-featureA feature request or enhancement
    on Nov 19, 2024
  2. self-assigned this
    on Nov 19, 2024
  3. nascheme commented on Nov 19, 2024

    @nascheme
    Member

    This sounds like a good idea to me.

  4. added a commit that references this issue on Nov 20, 2024
  5. added a commit that references this issue on Jan 12, 2025
  6. added a commit that references this issue on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usage

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions