Title: Do not simplify Union at runtime? · Issue #536 · python/typing · GitHub
Open Graph Title: Do not simplify Union at runtime? · Issue #536 · python/typing
X Title: Do not simplify Union at runtime? · Issue #536 · python/typing
Description: Currently unions are simplified at runtime, for example: class B: ... class C(B): ... assert Union[C, B] is B Also they are flattened, for example Union[A, Union[B, C]] evaluates to Union[A, B, C]. There are however some downsides: Simpl...
Open Graph Description: Currently unions are simplified at runtime, for example: class B: ... class C(B): ... assert Union[C, B] is B Also they are flattened, for example Union[A, Union[B, C]] evaluates to Union[A, B, C]....
X Description: Currently unions are simplified at runtime, for example: class B: ... class C(B): ... assert Union[C, B] is B Also they are flattened, for example Union[A, Union[B, C]] evaluates to Union[A, B, C]....
Opengraph URL: https://github.com/python/typing/issues/536
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Do not simplify Union at runtime?","articleBody":"Currently unions are simplified at runtime, for example:\r\n```python\r\nclass B: ...\r\nclass C(B): ...\r\nassert Union[C, B] is B\r\n```\r\nAlso they are flattened, for example `Union[A, Union[B, C]]` evaluates to `Union[A, B, C]`. There are however some downsides:\r\n* Simplification of unions is a concept related to static types, applying it at runtime might blur the distinction between static types and runtime classes.\r\n* Implementation of this feature had bugs, all of them related to the fact that `issublcass` is only applicable to proper classes, and it is not always easy to detect those beforehand.\r\n* This has some (although minor) runtime costs.\r\n\r\nOn the positive side:\r\n* This still teaches people how unions work with subclasses\r\n* It may be too late to change this.","author":{"url":"https://github.com/ilevkivskyi","@type":"Person","name":"ilevkivskyi"},"datePublished":"2018-01-29T23:50:52Z","url":"https://github.com/python/typing/issues/536"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f0e5a527-07e6-ec99-70fb-d0420be681a8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82D0:3DB50A:5A1437:78E557:6B00328A |
| html-safe-nonce | d87bbb3f3f78276318e548ab05b09515fd13fe287a50ba55975dd092047f5d94 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkQwOjNEQjUwQTo1QTE0Mzc6NzhFNTU3OjZCMDAzMjhBIiwidmlzaXRvcl9pZCI6IjQyNzk5ODQyNTcxMzg0Mzg3OTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4ff57ebc1a1f969d09b7e63789143fc531d68498720af704d28f6aa4e1409856 |
| hovercard-subject-tag | issue:292603850 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/typing/536/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c5443bc108215d4ded7aeb22dfd854e1c7580501173550d359836fc6c9969d6f/python/typing/issues/536 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c5443bc108215d4ded7aeb22dfd854e1c7580501173550d359836fc6c9969d6f/python/typing/issues/536 |
| og:image:alt | Currently unions are simplified at runtime, for example: class B: ... class C(B): ... assert Union[C, B] is B Also they are flattened, for example Union[A, Union[B, C]] evaluates to Union[A, B, C].... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilevkivskyi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typing git https://github.com/python/typing.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 24604008 |
| octolytics-dimension-repository_nwo | python/typing |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24604008 |
| octolytics-dimension-repository_network_root_nwo | python/typing |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width