Title: Experiment with backtracking in the new solver · Issue #15908 · python/mypy · GitHub
Open Graph Title: Experiment with backtracking in the new solver · Issue #15908 · python/mypy
X Title: Experiment with backtracking in the new solver · Issue #15908 · python/mypy
Description: Depend on #15906. This is a follow-up for series started by #15287 Currently when getting both upper and lower bounds for a type variable we randomly choose the lower one. This is not always the best choice and can lead to inference fail...
Open Graph Description: Depend on #15906. This is a follow-up for series started by #15287 Currently when getting both upper and lower bounds for a type variable we randomly choose the lower one. This is not always the be...
X Description: Depend on #15906. This is a follow-up for series started by #15287 Currently when getting both upper and lower bounds for a type variable we randomly choose the lower one. This is not always the be...
Opengraph URL: https://github.com/python/mypy/issues/15908
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Experiment with backtracking in the new solver","articleBody":"Depend on https://github.com/python/mypy/issues/15906. This is a follow-up for series started by https://github.com/python/mypy/pull/15287\r\n\r\nCurrently when getting both upper and lower bounds for a type variable we randomly choose the lower one. This is not always the best choice and can lead to inference failures. A possible example is:\r\n```\r\ndef dec(fn: Callable[[S, S, int], float]) -> Callable[[S], float]: ... \r\ndef f(x: List[float], y: List[T], z: T) -> T: ...\r\ndec(f)\r\n```\r\nthis will infer constraints like\r\n```\r\nS \u003c: List[float], S \u003c: List[T], T \u003c: float, T :> int\r\n```\r\nThey split into two SCCs each containing one variable `{T}` and `{S}`, and the second depends on first one. So we would first solve `T = int` and then we will get updated constraints for `S`: `S \u003c: List[float], S \u003c: List[int]`, with the only solution `S = \u003cnothing>`. At the same time `T = float, S = List[float]` is a totally valid solution. We could get it by backtracking when we get `\u003cnothing>` and trying different bound(s) in the previous SCC.\r\n\r\nOne possible problem I see is that this backtracking is exponential in worst case of inference failure (e.g. due to actual user error). Another problem is that backtracking can make implementation much less readable.\r\n\r\ncc @JukkaL ","author":{"url":"https://github.com/ilevkivskyi","@type":"Person","name":"ilevkivskyi"},"datePublished":"2023-08-18T17:00:40Z","url":"https://github.com/python/mypy/issues/15908"}
| 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:b2143a25-453a-d7ea-4d81-f97f95f38aeb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D56:2F0104:FF07E7:14EFA94:6B000635 |
| html-safe-nonce | ad793c217a079aa3872223345ef7a27827e4640dc7c06bd584cbc8b85ec7e49b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDU2OjJGMDEwNDpGRjA3RTc6MTRFRkE5NDo2QjAwMDYzNSIsInZpc2l0b3JfaWQiOiI3MzQ4NTA2NDEwMzU2ODM1ODkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0a6423489d6fc5ff29824d14720c0ca741db47fc3b991e14b7f6dd651f42fdd1 |
| hovercard-subject-tag | issue:1857022168 |
| 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/mypy/15908/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f91fdb0826c6ff2cfefbd5a6485ce9937f69b4b48257a30fe8f99c3a3330bd60/python/mypy/issues/15908 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f91fdb0826c6ff2cfefbd5a6485ce9937f69b4b48257a30fe8f99c3a3330bd60/python/mypy/issues/15908 |
| og:image:alt | Depend on #15906. This is a follow-up for series started by #15287 Currently when getting both upper and lower bounds for a type variable we randomly choose the lower one. This is not always the be... |
| 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 | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width