Title: mypy appears to become inefficient for nested ifs (13+ nested ifs) · Issue #9591 · python/mypy · GitHub
Open Graph Title: mypy appears to become inefficient for nested ifs (13+ nested ifs) · Issue #9591 · python/mypy
X Title: mypy appears to become inefficient for nested ifs (13+ nested ifs) · Issue #9591 · python/mypy
Description: Bug Report mypy appears to become inefficient for nested ifs (see example) To Reproduce Consider the following (bad) code example: cat << EOF > lint_me.py special_overrides = True print(sorted(["c", "b", "a"], key=lambda kv: kv[0] if not...
Open Graph Description: Bug Report mypy appears to become inefficient for nested ifs (see example) To Reproduce Consider the following (bad) code example: cat << EOF > lint_me.py special_overrides = True print(sorted(["c"...
X Description: Bug Report mypy appears to become inefficient for nested ifs (see example) To Reproduce Consider the following (bad) code example: cat << EOF > lint_me.py special_overrides = True print(so...
Opengraph URL: https://github.com/python/mypy/issues/9591
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy appears to become inefficient for nested ifs (13+ nested ifs)","articleBody":"\u003c!--\r\n If you're new to mypy and you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form\r\n instead.\r\n-->\r\n\r\n**Bug Report**\r\n\r\n\u003c!--\r\nNote: If the problem you are reporting is about a specific library function, then the typeshed tracker is better suited\r\nfor this report: https://github.com/python/typeshed/issues\r\n-->\r\nmypy appears to become inefficient for nested ifs (see example)\r\n\r\n**To Reproduce**\r\n\r\nConsider the following (bad) code example:\r\n```\r\ncat \u003c\u003c EOF > lint_me.py\r\nspecial_overrides = True\r\nprint(sorted([\"c\", \"b\", \"a\"], key=lambda kv: kv[0] if not special_overrides else \\\\\r\n 'a' if kv[0] == 'a_01' else \\\\\r\n 'b' if kv[0] == 'b_02' else \\\\\r\n 'c' if kv[0] == 'c_03' else \\\\\r\n 'd' if kv[0] == 'd_04' else \\\\\r\n 'e' if kv[0] == 'e_05' else \\\\\r\n 'f' if kv[0] == 'f_06' else \\\\\r\n 'g' if kv[0] == 'g_07' else \\\\\r\n 'h' if kv[0] == 'h_08' else \\\\\r\n 'i' if kv[0] == 'i_09' else \\\\\r\n 'j' if kv[0] == 'j_10' else \\\\\r\n 'k' if kv[0] == 'k_11' else \\\\\r\n 'l' if kv[0] == 'l_12' else \\\\\r\n 'm' if kv[0] == 'm_13' else \\\\\r\n 'n' if kv[0] == 'n_14' else \\\\\r\n 'o' if kv[0] == 'o_15' else \\\\\r\n 'p' if kv[0] == 'p_16' else \\\\\r\n 'q' if kv[0] == 'q_17' else \\\\\r\n kv[0]))\r\nEOF\r\n```\r\n\r\n\r\n**Expected Behavior**\r\nmypy can complain about very bad code in a reasonable time\r\n\r\n**Actual Behavior**\r\nwith each additional `if` the total runtime seems to double:\r\n```\r\n13 nested ifs (until m): real 0m33.827s\r\n14 nested ifs (until n): real 1m10.013s\r\n15 nested ifs (until o): real 2m3.904s\r\n16 nested ifs (until p): real 4m3.223s\r\n17 nested ifs (until q): real 8m27.333s\r\n```\r\n\r\n**Your Environment**\r\n\r\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n- Mypy version used: `0.790`\r\n- Mypy command-line flags: None (just `python -m mypy lint_me.py`)\r\n- Mypy configuration options from `mypy.ini` (and other config files): None\r\n- Python version used: `Python 3.8.1`\r\n- Operating system and version: `Windows 10, Version 10.0.19041 Build 19041`\r\n","author":{"url":"https://github.com/stmlange","@type":"Person","name":"stmlange"},"datePublished":"2020-10-13T17:23:48Z","url":"https://github.com/python/mypy/issues/9591"}
| 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:7ada1feb-b8ba-68c5-df06-4ac353635e49 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE82:1DD784:190B42:218D47:6B002011 |
| html-safe-nonce | 34dbd17bbd8a2a3ee8f77c369bfd991a36c2d02196004cec0e0a072fe332cd2b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTgyOjFERDc4NDoxOTBCNDI6MjE4RDQ3OjZCMDAyMDExIiwidmlzaXRvcl9pZCI6IjIwMTc3ODkxNDA4MzMxNDg5NDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4577f41b73ec7dbc32b7197cca69173053151407507e97c1e55cdd03de2cc8c8 |
| hovercard-subject-tag | issue:720573857 |
| 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/9591/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56678746c89b079e9b67042ab862cfa77bd4c97c440bd8868aca519391737fb5/python/mypy/issues/9591 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56678746c89b079e9b67042ab862cfa77bd4c97c440bd8868aca519391737fb5/python/mypy/issues/9591 |
| og:image:alt | Bug Report mypy appears to become inefficient for nested ifs (see example) To Reproduce Consider the following (bad) code example: cat << EOF > lint_me.py special_overrides = True print(sorted(["c"... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | stmlange |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width