Title: pydoc is obscenely slow for some modules · Issue #118465 · python/cpython · GitHub
Open Graph Title: pydoc is obscenely slow for some modules · Issue #118465 · python/cpython
X Title: pydoc is obscenely slow for some modules · Issue #118465 · python/cpython
Description: For example, ./python -m pydoc test.test_enum takes 32 seconds. It is 20 seconds in 3.12, 15 seconds in 3.11 and only 1.6 seconds in 3.10. Well, perhaps test.test_enum was grown, but the main culprit is bpo-35113. And further changes lik...
Open Graph Description: For example, ./python -m pydoc test.test_enum takes 32 seconds. It is 20 seconds in 3.12, 15 seconds in 3.11 and only 1.6 seconds in 3.10. Well, perhaps test.test_enum was grown, but the main culpr...
X Description: For example, ./python -m pydoc test.test_enum takes 32 seconds. It is 20 seconds in 3.12, 15 seconds in 3.11 and only 1.6 seconds in 3.10. Well, perhaps test.test_enum was grown, but the main culpr...
Opengraph URL: https://github.com/python/cpython/issues/118465
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pydoc is obscenely slow for some modules","articleBody":"For example, `./python -m pydoc test.test_enum` takes 32 seconds. It is 20 seconds in 3.12, 15 seconds in 3.11 and only 1.6 seconds in 3.10. Well, perhaps `test.test_enum` was grown, but the main culprit is bpo-35113. And further changes like gh-106727 only added to it.\r\n\r\nFor every class without a docstring `pydoc` tries to find its comments by calling `inspect.getcomments()` which calls `inspect.findsource()` which reads and parses the module source, then traverse it and find classes with the specific qualname. For large modules with many classes it has quadratic complexity.\r\n\r\nI tried to optimize the AST traversing code, and get 18 seconds on main. It still has quadratic complexity. Further optimization will require introducing a cache and finding positions of all classes in one pass.\r\n\r\nBut it all would be much simpler and faster if simply save the value of `co_firstlineno` of the code object executed during class creation in the file dict (as `__firstlineno__` for example).\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-118471\n* gh-118475\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2024-05-01T10:01:18Z","url":"https://github.com/python/cpython/issues/118465"}
| 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:01e58af0-7c26-35c1-d75d-4f6b45a95b60 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B08:395268:16721EA:1D934D0:6B066863 |
| html-safe-nonce | 82ca1e9a732666e3c378a916a21a6bf232cd1f851d259c75e284a31f7211a747 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjA4OjM5NTI2ODoxNjcyMUVBOjFEOTM0RDA6NkIwNjY4NjMiLCJ2aXNpdG9yX2lkIjoiNjMxMDY3OTUxODQ3ODYwMzIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d4ad081731f76ce1dd1f9aa5602bafded54e222148d093bf8726bd8319e1f656 |
| hovercard-subject-tag | issue:2273263590 |
| 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/cpython/118465/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8d4f45c495acbe94a79d4c187c766921301d9463a04b373634fd271b8e6a1d6c/python/cpython/issues/118465 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8d4f45c495acbe94a79d4c187c766921301d9463a04b373634fd271b8e6a1d6c/python/cpython/issues/118465 |
| og:image:alt | For example, ./python -m pydoc test.test_enum takes 32 seconds. It is 20 seconds in 3.12, 15 seconds in 3.11 and only 1.6 seconds in 3.10. Well, perhaps test.test_enum was grown, but the main culpr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width