FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve object traversal for heap types and mro by youknowone · Pull Request #6976 · RustPython/RustPython · GitHub

Improve object traversal for heap types and mro - #6976

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowone:traverse-improvements
Feb 3, 2026
Merged

Improve object traversal for heap types and mro#6976
youknowone merged 1 commit into
RustPython:mainfrom
youknowone:traverse-improvements

Conversation

youknowone commented Feb 3, 2026
edited by coderabbitai Bot
Loading

Copy link
Copy Markdown
Member
  • 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.

- 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

Copy link
Copy Markdown
Contributor
📝 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 docstrings
🧪 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.

youknowone marked this pull request as ready for review February 3, 2026 08:10
youknowone merged commit d6aab01 into RustPython:main Feb 3, 2026
13 checks passed
youknowone deleted the traverse-improvements branch February 3, 2026 08:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL