frozenset() created from a set literal is not untracked by the GC
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
gh-140232 made frozensets untracked by the GC when none of their elements can be tracked. However, the compiler's fast path for frozenset({...}) and frozenset({... for ...}) freezes the built set in place with _PySet_Freeze() (INTRINSIC_BUILD_FROZENSET), which skips that check, so the result stays tracked:
>>> import gc
>>> s = {1, 2}
>>> gc.is_tracked(frozenset(s))
False
>>> gc.is_tracked(frozenset({1, 2}))
True
I'm preparing a PR for this.
Linked PRs
- gh-155182
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer using gc.is_tracked, then inspect the compiler fast path named INTRINSIC_BUILD_FROZENSET and _PySet_Freeze(). Done means frozenset({...}) and frozenset({... for ...}) have the same tracking behavior as frozenset(s), with coverage for the reported cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100