You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 the urllib imports.
Lazily 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.
Before:
[jelle@natrium][~/projects/cpython]%hyperfine -w 5 "./python -c 'import xml.sax.saxutils'"
Benchmark 1: ./python -c 'import xml.sax.saxutils' (85 runs)
mean ± σ min … max
Wall Time 34.3 ms ± 1.4 ms 32.6 ms … 42.0 ms
Memory 20.3 MiB ± 0.2 MiB 19.7 MiB … 20.6 MiB
After
[jelle@natrium][~/projects/cpython]%hyperfine -w 5 "./python -c 'import xml.sax.saxutils'"
Benchmark 1: ./python -c 'import xml.sax.saxutils' (271 runs)
mean ± σ min … max
Wall Time 10.6 ms ± 0.5 ms 9.1 ms … 11.6 ms
Memory 10.2 MiB ± 0.1 MiB 9.8 MiB … 10.4 MiB
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Activity