Performance of typing._ProtocolMeta._get_protocol_attrs and isinstance · Issue #74690 · python/cpython · GitHub

github.com

Tin mới

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

3.12only security fixes

performancePerformance or resource usage

stdlibStandard Library Python modules in the Lib/ directory

gh-74690: typing: Don't unnecessarily call _get_protocol_attrs twice in _ProtocolMeta.__instancecheck__ #103141

gh-74690: Micro-optimise typing._get_protocol_attrs #103152

gh-74690: typing: Simplify and optimise _ProtocolMeta.__instancecheck__ #103159

gh-74690: typing: Call _get_protocol_attrs and _callable_members_only at protocol class creation time, not during isinstance() checks #103160

gh-74690: Further optimise typing._ProtocolMeta.__instancecheck__ #103280

gh-74690: typing._ProtocolMeta.__instancecheck__: Exit early for protocols that only have callable members #103310

gh-74690: Add more tests for runtime-checkable protocols #103347

gh-74690: Document changes made to runtime-checkable protocols in 3.12 #103348

[3.11] gh-74690: Add more tests for runtime-checkable protocols (GH-103347) #103350

gh-74690: Don't set special protocol attributes on non-protocol subclasses of protocols #104622

gh-74690: Make a typing test more resilient #104691

gh-74690: Improve performance when testing against protocols with many attributes. #112157

gh-74690: Optimise isinstance() and issubclass() calls against runtime-checkable protocols by avoiding costly super() calls #112708

gh-74690: Avoid a costly type check where possible in _ProtocolMeta.__subclasscheck__ #112717