René's URL Explorer Experiment


Title: Kill __subclasscheck__ by ilevkivskyi · Pull Request #283 · python/typing · GitHub

Open Graph Title: Kill __subclasscheck__ by ilevkivskyi · Pull Request #283 · python/typing

X Title: Kill __subclasscheck__ by ilevkivskyi · Pull Request #283 · python/typing

Description: This PR: Fixes #136 Fixes #133 Partially fixes #203 (fixes the isinstance part, and multiple inheritance, still typing.Something is not a drop-in replacement for collections.abc.Something in terms of implementation). Also fixes http://bugs.python.org/issue26075, http://bugs.python.org/issue25830, and http://bugs.python.org/issue26477 Makes almost everything up to 10x faster. Is aimed to be a minimalistic change. I only removed issubclass tests from test_typing and main changes to typing are __new__ and __getitem__. The idea is to make most things not classes. Now _ForwardRef(), TypeVar(), Union[], Tuple[], Callable[] are not classes (i.e. new class objects are almost never created by typing). Using isinstance() or issubclass() rises TypeError for almost everything. There are exceptions: Unsubscripted generics are still OK, e.g. issubclass({}, typing.Mapping). This is done to (a) not break existing code by addition of type information; (b) to allow using typing classes as a replacement for collections.abc in class and instance checks. Finally, there is an agreement that a generic without parameters assumes Any, and Any means fallback to dynamic typing. isinstance(lambda x: x, typing.Callable) is also OK. Although Callable is not a generic class, when unsubscribed, it could be also used as a replacement for collections.abc.Callable. The first rule for generics makes isinstance([], typing.List) possible, for consistency I also allowed isinstance((), typing.Tuple). Finally, generics should be classes, to allow subclassing, but now the outcome of __getitem__ on classes is cached. I use an extended version of functools.lru_cache that allows fallback to non-cached version for unhashable arguments. This is still WIP, since I did this only for Python 3. @gvanrossum @JukkaL Please take a look.

Open Graph Description: This PR: Fixes #136 Fixes #133 Partially fixes #203 (fixes the isinstance part, and multiple inheritance, still typing.Something is not a drop-in replacement for collections.abc.Something in terms...

X Description: This PR: Fixes #136 Fixes #133 Partially fixes #203 (fixes the isinstance part, and multiple inheritance, still typing.Something is not a drop-in replacement for collections.abc.Something in terms...

Opengraph URL: https://github.com/python/typing/pull/283

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:3d58ac01-b890-515a-60d0-7f7ec1ae0fe2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id80B4:07D0:14B1E2C:1B4603D:6B001A84
html-safe-nonce27beae4abf70bba335237dff3503f45918a19d95afe454e8418a4d62a4ed19aa
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEI0OjA3RDA6MTRCMUUyQzoxQjQ2MDNEOjZCMDAxQTg0IiwidmlzaXRvcl9pZCI6Ijc0NDU4NjQxMTkxMzcyMTMwNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc3586183841d2c584de26b03f512e9d668021673cce059587a3a8c8db327255d
hovercard-subject-tagpull_request:85725093
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/typing/pull/283/files
twitter:imagehttps://avatars.githubusercontent.com/u/12005495?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/12005495?s=400&v=4
og:image:altThis PR: Fixes #136 Fixes #133 Partially fixes #203 (fixes the isinstance part, and multiple inheritance, still typing.Something is not a drop-in replacement for collections.abc.Something in terms...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/typing git https://github.com/python/typing.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id24604008
octolytics-dimension-repository_nwopython/typing
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24604008
octolytics-dimension-repository_network_root_nwopython/typing
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release44c658b24abf00491fb7ae5f56d42c9f38cbeab2
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/typing/pull/283/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fpull%2F283%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftyping%2Fpull%2F283%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Ftyping
Reloadhttps://github.com/python/typing/pull/283/files
Reloadhttps://github.com/python/typing/pull/283/files
Reloadhttps://github.com/python/typing/pull/283/files
pythonhttps://github.com/python
typinghttps://github.com/python/typing
Codehttps://github.com/python/typing
Issues206 (206)https://github.com/python/typing/issues
Pull requests27 (27)https://github.com/python/typing/pulls
Discussionshttps://github.com/python/typing/discussions
Actionshttps://github.com/python/typing/actions
Security and qualityhttps://github.com/python/typing/security
Insightshttps://github.com/python/typing/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Ftyping%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Ftyping%2Fissues%2Fnew%2Fchoose
gvanrossumhttps://github.com/gvanrossum
python:masterhttps://github.com/python/typing/tree/master
ilevkivskyi:masterhttps://github.com/ilevkivskyi/typehinting/tree/master
Conversation 28 https://github.com/python/typing/pull/283
Commits 28 https://github.com/python/typing/pull/283/commits
Checks 0 https://github.com/python/typing/pull/283/checks
Files changed https://github.com/python/typing/pull/283/files
Please reload this pagehttps://github.com/python/typing/pull/283/files
Kill __subclasscheck__ https://github.com/python/typing/pull/283/files#top
Show all changes 28 commits https://github.com/python/typing/pull/283/files
7d73596 Started #136 ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/7d73596a745882f7d4cd65749988f09f191b02b1
20de824 Started #136 ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/20de824f97409417d5c16673c044e8c6a027e2a1
8e6f0a6 More work on #136 ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/8e6f0a689a8f7871593d74a5ec32068e6c891c58
bcde4c6 Finish first round of #136 ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/bcde4c6f8bfbf815f0dfb217d5fe59eba806d8eb
9987bb2 Shorter error messages ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/9987bb2ae5a17c05361fff5d040a7968d1a1b41e
90d72da Added lru_cache for Generic[] ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/90d72da6f2cd79970d5205d4faaaf644ce68bdfb
603ff6d Flexible cache for Generic[] ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/603ff6d8e6285f9aeb4e49df1e7d0ccd46a35294
fa4a681 Skip GenericMeta in FrozenSetMeta MRO ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/fa4a681d8624d75bd71816b3473d9e85a526513d
cc99972 Revert "Skip GenericMeta in FrozenSetMeta MRO" ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/cc999722865e7a6f7250f3c2b318f3fa530385db
b587dc0 Remove redundant metaclass for frozenset ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/b587dc0fc622d5b51057a88d2aeee55851d5757b
e25b303 Some formatting ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/e25b303f2a7c82d3870bdc6080ff31334d96ed1f
3ccb7a9 Fix async/await tests ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/3ccb7a9038bc5b895ef378ba47f40b213d62f867
0606059 Fixed ContextManger test ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/0606059f8d2336068732cec5200b813edbc8fac1
8b909d6 Be consistent about _TypeAlias ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/8b909d6b53b331b7371e0b29a6c0fe4f6250215f
554f2ed Removed debugging print() ilevkivskyi Sep 18, 2016 https://github.com/python/typing/pull/283/commits/554f2edce00608200db38422cc4441a8c852ef81
11189b0 Simplified code ilevkivskyi Sep 19, 2016 https://github.com/python/typing/pull/283/commits/11189b05a7066084bb35a0c469b51ac25187a4bd
4c91c3b Increased cache size to 50; start backporting changes to Python 2 ilevkivskyi Sep 22, 2016 https://github.com/python/typing/pull/283/commits/4c91c3b86781cda840bb64a411e5b52c0db605a5
1920009 Backport Union and Optional to Python 2 ilevkivskyi Sep 23, 2016 https://github.com/python/typing/pull/283/commits/192000937d5c028a48316e6b018ecad348110794
f003eca Finished backport to Python 2; some polishing is needed ilevkivskyi Sep 23, 2016 https://github.com/python/typing/pull/283/commits/f003eca45e059babf543d5ec24b135961fafad20
e130c77 Added many unit tests for bugs fixed by PR ilevkivskyi Sep 24, 2016 https://github.com/python/typing/pull/283/commits/e130c770d7fd3bb3a908f259e7587eb8a600700e
fe2d3b7 Updated docstrings and other minor things ilevkivskyi Sep 24, 2016 https://github.com/python/typing/pull/283/commits/fe2d3b797ea7adf809638ff953baa9618993e19a
e4cebff Optimized caching + first part of response to comments ilevkivskyi Sep 25, 2016 https://github.com/python/typing/pull/283/commits/e4cebff3dfb7c2cd8c70396ca24a033a464183a5
9b443cb Second part of response to comments. Need to port all comments etc. t… ilevkivskyi Sep 26, 2016 https://github.com/python/typing/pull/283/commits/9b443cb45934b8e515c62ab5ad571b5571008139
bd160a1 Start backporting comments to Python2; improve caching ilevkivskyi Sep 26, 2016 https://github.com/python/typing/pull/283/commits/bd160a143ef676cce8073330b2af8053c2f3ee94
80ce513 Get rid of frozensetmeta, it causes random failures ilevkivskyi Sep 26, 2016 https://github.com/python/typing/pull/283/commits/80ce5134ef36451331380ce99964b360ec5c9ecb
c4f11e8 Backported everything to Python 2 Sep 26, 2016 https://github.com/python/typing/pull/283/commits/c4f11e88b252d2625c302c3d85bd86d066381447
230a500 Do not duplicate real errors while caching ilevkivskyi Sep 26, 2016 https://github.com/python/typing/pull/283/commits/230a500b7f0081f192dcbd989597fbe72627321a
e8c85b2 Merge remote-tracking branch 'origin/master' ilevkivskyi Sep 26, 2016 https://github.com/python/typing/pull/283/commits/e8c85b26ea5e48da7e26162327a7cb8a919bbe84
Clear filters https://github.com/python/typing/pull/283/files
Please reload this pagehttps://github.com/python/typing/pull/283/files
Please reload this pagehttps://github.com/python/typing/pull/283/files
test_typing.py https://github.com/python/typing/pull/283/files#diff-f23c53e6fa002cdeac74b9499d744b9492bfd34a58ce281c2b5076e628d0083a
typing.py https://github.com/python/typing/pull/283/files#diff-cbea31cd6366bdaf7805202979325ba4b14a29613bb7aeaecf9a18e94ea93619
test_typing.py https://github.com/python/typing/pull/283/files#diff-e618ee6a4894a62d9269e41c4dc836e31e8224cfb66b5be3b325f4798ec245e3
typing.py https://github.com/python/typing/pull/283/files#diff-ad6da8dfad5c336100410e57073641a0266b69e1801476d2b1e593b2c04f81f5
Please reload this pagehttps://github.com/python/typing/pull/283/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.