Title: Lazy load urllib modules in saxutils · Issue #159675 · python/cpython · GitHub
Open Graph Title: Lazy load urllib modules in saxutils · Issue #159675 · python/cpython
X Title: Lazy load urllib modules in saxutils · Issue #159675 · python/cpython
Description: Feature or enhancement import xml.sax.saxutils Firewalld, a popular Linux firewall daemon uses xml.sax to read/write XML files, like most other consumers it does not call prepare_input_source() which is the only function which relies on ...
Open Graph Description: Feature or enhancement import xml.sax.saxutils Firewalld, a popular Linux firewall daemon uses xml.sax to read/write XML files, like most other consumers it does not call prepare_input_source() whi...
X Description: Feature or enhancement import xml.sax.saxutils Firewalld, a popular Linux firewall daemon uses xml.sax to read/write XML files, like most other consumers it does not call prepare_input_source() whi...
Opengraph URL: https://github.com/python/cpython/issues/159675
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Lazy load urllib modules in saxutils","articleBody":"### Feature or enhancement\n\n```python\nimport xml.sax.saxutils\n```\n\nFirewalld, a popular Linux firewall daemon uses `xml.sax` to read/write XML files, like most other consumers it does not call `prepare_input_source()` which is the only function which relies on the urllib imports.\n\nLazily loading the modules shaves off 3M memory usage (48M before -> 45M after), additionally it makes importing saxutils 3x faster but that is not super important.\n\nBefore:\n```\n[jelle@natrium][~/projects/cpython]%hyperfine -w 5 \"./python -c 'import xml.sax.saxutils'\"\nBenchmark 1: ./python -c 'import xml.sax.saxutils' (85 runs)\n mean ± σ min … max\n Wall Time 34.3 ms ± 1.4 ms 32.6 ms … 42.0 ms\n Memory 20.3 MiB ± 0.2 MiB 19.7 MiB … 20.6 MiB\n```\n\nAfter\n```\n[jelle@natrium][~/projects/cpython]%hyperfine -w 5 \"./python -c 'import xml.sax.saxutils'\"\nBenchmark 1: ./python -c 'import xml.sax.saxutils' (271 runs)\n mean ± σ min … max\n Wall Time 10.6 ms ± 0.5 ms 9.1 ms … 11.6 ms\n Memory 10.2 MiB ± 0.1 MiB 9.8 MiB … 10.4 MiB\n```\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159676\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/jelly","@type":"Person","name":"jelly"},"datePublished":"2026-10-18T13:40:19Z","url":"https://github.com/python/cpython/issues/159675"}
| 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:70e7e4b8-4d8e-1575-d7ac-88ac03521a7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8CA:2E3FEE:3D7EE96:4DD6423:6B0207B5 |
| html-safe-nonce | 3ba5ece1be37733e2cacf27f13f9326380260499a93b8110092c6080bbd55a3e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOENBOjJFM0ZFRTozRDdFRTk2OjRERDY0MjM6NkIwMjA3QjUiLCJ2aXNpdG9yX2lkIjoiNTc3NDcwNDEyMTA2NDA2NDk0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 089e54c2b8b381ba439b850150fe5c0b30b959dcc3ea6fb29ba2e3c209de4b43 |
| hovercard-subject-tag | issue:5910112966 |
| 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/159675/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9f5ba989b40eda168c53e71adb795f21bdc75f3e399c44911f37ae30450c372f/python/cpython/issues/159675 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f5ba989b40eda168c53e71adb795f21bdc75f3e399c44911f37ae30450c372f/python/cpython/issues/159675 |
| og:image:alt | Feature or enhancement import xml.sax.saxutils Firewalld, a popular Linux firewall daemon uses xml.sax to read/write XML files, like most other consumers it does not call prepare_input_source() whi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jelly |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width