gh-103193: cache calls to `inspect._shadowed_dict` in `inspect.getattr_static` by AlexWaygood · Pull Request #104267 · python/cpython · GitHub

github.com

Tin mới

AlexWaygood:simple-lru-cache

GitHub CopilotWrite better code with AI

GitHub Copilot appDirect agents from issue to merge

ActionsAutomate any workflow

CodespacesInstant dev environments

IssuesPlan and track work

Code ReviewManage code changes

Code QualityEnforce quality at merge

GitHub Advanced SecurityFind and fix vulnerabilities

Code securitySecure your code as you build

Secret protectionStop leaks before they start

View all use cases

Financial services

View all industries

Software Development

GitHub SponsorsFund open source developers

Copilot for BusinessEnterprise-grade AI features

Premium SupportEnterprise-grade 24/7 support

Pull requests 2.6k

Security and quality 0

Optimise inspect.getattr_static #103193

: cache calls to inspect._shadowed_dict

Use mro tuple as the cache key

View reviewed changes

Learn more about hiding disruptive comments

The reason will be displayed to describe this comment to others. Learn more.

Add regression test for if a class has its mro mutated(!)

Update perf numbers in whatsnew

awaiting core review

awaiting core review

https://github.com/python/cpython/pull/103195/files

(Skipping news because, if this patch is correct, it shouldn't change behaviour at all other than improving performance. And the news entry in https://github.com/python/cpython/pull/103195/files should already cover the

View reviewed changes

gh-103193: cache calls to `inspect._shadowed_dict` in `inspect.getattr_static` (#104267) Co-authored-by: Carl Meyer <[email protected]>

[3.12] getattr_static can result in reference leaks #118013

gh-118013: Use weakrefs for the cache key in inspect._shadowed_dict #118202