GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve object traversal for heap types and mro by youknowone · Pull Request #6976 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Feb 3, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
Improve object traversal for heap types and mro
f358d86
- 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

coderabbitai Bot commented Feb 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

  • make mro representation fit to CPython #5866: Directly modifies PyType traverse/mro behavior related to this PR's MRO tracing enablement.
  • traverse and clear #6780: Also modifies object traversal logic in traverse_object.rs, rewiring traversal hooks that interact with these changes.

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone marked this pull request as ready for review February 3, 2026 08:10
@youknowone
youknowone merged commit d6aab01 into RustPython:main Feb 3, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone deleted the traverse-improvements branch February 3, 2026 08:54
@coderabbitai coderabbitai Bot mentioned this pull request Feb 3, 2026
Add GC infrastructure: tracking bits, tp_clear #6977
Merged
youknowone added a commit that referenced this pull request Sep 16, 2026
@youknowone
Improve object traversal for heap types and mro (#6976)
1509195
- 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

1 participant

@youknowone
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.