Title: gh-74690: Avoid a costly type check where possible in `_ProtocolMeta.__subclasscheck__` by AlexWaygood · Pull Request #112717 · python/cpython · GitHub
Open Graph Title: gh-74690: Avoid a costly type check where possible in `_ProtocolMeta.__subclasscheck__` by AlexWaygood · Pull Request #112717 · python/cpython
X Title: gh-74690: Avoid a costly type check where possible in `_ProtocolMeta.__subclasscheck__` by AlexWaygood · Pull Request #112717 · python/cpython
Description: This speeds up issubclass(int, typing.SupportsIndex) by around 6%. The approach is to move the code around a bit so that we delegate the type-checking to type.__subclasscheck__ wherever possible; type.__subclasscheck__ can do it faster. We now only check from _ProtocolMeta.__subclasscheck__ whether other is an instance of type if we know we're about to raise an exception anyway, and we want the issubclass() arg 2 must be a type message to take priority over the other error message we could potentially give the user. Issue: gh-74690
Open Graph Description: This speeds up issubclass(int, typing.SupportsIndex) by around 6%. The approach is to move the code around a bit so that we delegate the type-checking to type.__subclasscheck__ wherever possible; t...
X Description: This speeds up issubclass(int, typing.SupportsIndex) by around 6%. The approach is to move the code around a bit so that we delegate the type-checking to type.__subclasscheck__ wherever possible; t...
Opengraph URL: https://github.com/python/cpython/pull/112717
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8e9c843f-9f44-59d4-990b-b7714c3c33f8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C01A:1FC3E6:AC6F3C:F27DC8:696A1D36 |
| html-safe-nonce | 9d196e484ea01f5d6ae518afa98bd3089f7446a9308c78d27a9a5355e5e3b4d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDFBOjFGQzNFNjpBQzZGM0M6RjI3REM4OjY5NkExRDM2IiwidmlzaXRvcl9pZCI6IjEzNTA5MTgyMjMxMTU3MjIwMzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cca2d6c6174cf99b6be3293b264b465bc2c98eff0108b4f9b47cd08468e3da41 |
| hovercard-subject-tag | pull_request:1628706137 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/112717/files |
| twitter:image | https://avatars.githubusercontent.com/u/66076021?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/66076021?s=400&v=4 |
| og:image:alt | This speeds up issubclass(int, typing.SupportsIndex) by around 6%. The approach is to move the code around a bit so that we delegate the type-checking to type.__subclasscheck__ wherever possible; t... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 014f3d193f36b7d393f88ca22d06fbacd370800b40a547c1ea67291e02dc8ea3 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d515f6f09fa57a93bf90355cb894eb84ca4f458f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width