Repository navigation
Collect cycles through sets, frozensets and set iterators - #9343
Conversation
Assisted-by: Codex:GPT-6
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Payload GC and deallocation policy crates/vm/src/object/payload.rs, crates/vm/src/object/core.rs |
PyPayload adds needs_gc and CLEAR_ON_DEALLOC. Object creation uses the payload’s GC eligibility alongside dict-backed and heap-type tracking rules. Default deallocation clears payloads only when the payload opts in or uses a freelist. |
Set traversal, tracking, and validation crates/vm/src/builtins/set.rs, crates/vm/src/dict_inner.rs |
Set payloads manually traverse and clear table entries only when the table has one owner. Frozenset tracking checks subclasses, table sharing, and key GC edges. Tests cover deferred key release, shared tables, and frozenset tracking cases. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Suggested reviewers: youknowone, shaharnaveh
Merge Risk: 
Minimal · up to cbf92
-
No actionable merge-blocking risk remains; the change is mergeable after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "Collect cycles through sets, frozensets and set iterators" matches the main change. The raw summary and PR objectives show GC traversal and clearing for PySet, PyFrozenSet, and set iterators, plus the needs_gc and CLEAR_ON_DEALLOC additions that support cycle collection through these types. The title is specific and concise, and it names the primary change for a reviewer scanning history.
-
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [ ] test: cpython/Lib/test/test_set.py (TODO: 1) dependencies: dependent tests: (no tests depend on set) Legend:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbf92d3163
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Integrate main at 9bd84b2 while preserving the published mega history. Keep the authentic profiler locator and capabilities from RustPython#9340, set-cycle GC from RustPython#9343, backward-compatible bytecode tooling from RustPython#9344, package paths from RustPython#9345, canonical Levenshtein coverage from RustPython#9346, and the safe full-width None-return scanner from RustPython#9347. Regenerate support helpers through the official updater from unchanged CPython d220409a13b7, preserving four exact existing-main neighborhoods. Retain the newer main specialization/C-stack helpers, Cargo environment adaptation, prior isolation checks and remaining Python 3.15 updates. The obsolete manual capability guard is superseded by the genuine API. Preserve unlanded explicit sharing modes and opcode override support. Ruff and XML vendor sources remain unchanged. Validation: normal hooks, locked host_env/VM/stdlib library check and strict Clippy, and the default CLI build. No target-runtime or full-suite pass is claimed for this composition. Assisted-by: OpenAI Codex:model version unavailable
Found while testing collection adapters for an embedding application: a native object holding a plain
PyRef<PySet>remained allocated when the set contained that object.Summary
Performance
Three full collections release all 3,000 native/set cycles in the reproduction on both systems; previously none of the native payloads were released.
Windows 11 x64
Debian 13 amd64
Checking frozenset eligibility adds a linear scan of the result's keys. The union measurements include destruction of the temporary result.
AI assistance
Written with Codex (GPT-6), reviewed by a human before submission.
Summary by CodeRabbit