◐ Shell
clean mode source ↗

Add method cache for MRO lookups by youknowone · Pull Request #7313 · RustPython/RustPython

coderabbitai[bot]

coderabbitai[bot]

coderabbitai[bot]

@youknowone youknowone changed the title Add type attribute cache (MCACHE) for MRO lookups Add method cache for MRO lookups

Mar 3, 2026
4096-entry direct-mapped cache keyed by (tp_version_tag, interned_name_ptr)
using lock-free SeqLock pattern for concurrent access.

- find_name_in_mro() checks cache before MRO walk
- has_name_in_mro() avoids cloning on cache hit
- Auto-assigns version tags on cache miss
- Invalidation via modified() (tp_version_tag=0) with value drops
- TYPE_CACHE_CLEARING flag suppresses re-population during GC drops
- Clear method cache during GC collection to break reference cycles

This was referenced

Mar 5, 2026

youknowone added a commit to youknowone/RustPython that referenced this pull request

Mar 22, 2026
4096-entry direct-mapped cache keyed by (tp_version_tag, interned_name_ptr)
using lock-free SeqLock pattern for concurrent access.

- find_name_in_mro() checks cache before MRO walk
- has_name_in_mro() avoids cloning on cache hit
- Auto-assigns version tags on cache miss
- Invalidation via modified() (tp_version_tag=0) with value drops
- TYPE_CACHE_CLEARING flag suppresses re-population during GC drops
- Clear method cache during GC collection to break reference cycles