Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimiseinspect.getattr_static #103193

Closed
Closed
Assignees
AlexWaygood
Labels
3.12only security fixesperformancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement
@AlexWaygood

Description

@AlexWaygood

Feature or enhancement

Following 6d59c9e,typing._ProtocolMeta.__instancecheck__ usesinspect.getattr_static in a tight loop, where it had previously usedhasattr. This improves semantics in several highly desirable ways, but causes a considerable slowdown for_ProtocolMeta.__instancecheck__, asinspect.getattr_static ismuch slower thanhasattr.

The performance hit to_ProtocolMeta.__instancecheck__ has already been mostly mitigated through severaltyping-specific optimisations that are tracked in this issue:

However, it would be good to also see if we can improve the performance ofinspect.getattr_static. This will not only improve the performance ofisinstance() checks against classes subclassingtyping.Protocol. It will also improve the performance of all other tools that useinspect.getattr_static for introspection without side effects.

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixesperformancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp