GeezerVison is showing github.com — Improve object traversal for heap types and mro by youknowone · Pull Request #6976 · RustPython/RustPython
Conversation
youknowone
commented
Feb 3, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
- Fix heap type instance traversal to include type reference (enables correct cycle detection for instance ↔ type references)
- Enable mro traversal in PyType (was previously disabled)
Summary by CodeRabbit
- Refactor
- Improved garbage collection traversal for type objects to ensure proper memory management of type hierarchies and heap-allocated types.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- Fix heap type instance traversal to include type reference
(enables correct cycle detection for instance ↔ type references)
- Enable mro traversal in PyType (was previously disabled)
coderabbitai
Bot
commented
Feb 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
📝 Walkthrough
Walkthrough
This PR enhances garbage collection tracing in the RustPython VM by re-enabling MRO traversal in PyType and adding explicit heap-type reference tracing in PyInner object traversal. These changes ensure complete marking of type relationships during GC cycles.
Changes
| Cohort / File(s) |
Summary |
GC Traversal Enablement crates/vm/src/builtins/type.rs |
Re-enabled MRO traversal in PyType's traverse implementation by uncommenting self.mro.traverse(tracer_fn), ensuring all MRO entries are visited during GC tracing. |
Heap Type Reference Tracing crates/vm/src/object/traverse_object.rs |
Added explicit tracing of heap-type references in both PyInner and PyInner paths. When a type is a heap type, the type object is now converted to PyObject and traced before dict/slots traversal continues. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~22 minutes
Possibly related PRs
Poem
🐰 Hop, hop, the MRO flows,
No more gaps in traces that the garbage knows,
Heap types shine with reference bright,
GC cycles now collect all in sight! ✨
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title 'Improve object traversal for heap types and mro' directly and accurately summarizes the main changes: enabling MRO traversal in PyType and improving heap type instance traversal to include type references. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
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.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
youknowone
added a commit
that referenced
this pull request
Sep 16, 2026
- Fix heap type instance traversal to include type reference
(enables correct cycle detection for instance ↔ type references)
- Enable mro traversal in PyType (was previously disabled)
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.