GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Lazy load urllib modules in saxutils · Issue #159675 · python/cpython

Lazy load urllib modules in saxutils #159675

New issue
Copy link
New issue
Copy link
Closed
Closed
Lazy load urllib modules in saxutils#159675
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-lazy-importstype-featureA feature request or enhancementA feature request or enhancement

Description

@jelly
jelly
opened on Oct 18, 2026
Issue body actions

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 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

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-159675: Use lazy urllib imports in saxutils #159676

Activity

  1. jelly
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Oct 18, 2026
  2. hugovk
    added a parent issue on Oct 18, 2026
    • Improve import time of various stdlib modules #154675
  3. aisk
    added
    topic-lazy-imports
    on Oct 18, 2026
  4. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Oct 18, 2026
  5. kevinprimeraquecreo-stack
    added this to Project_VKand Project_VKon Oct 18, 2026
  6. github-project-automation
    moved this to Todo in Project_VKon Oct 18, 2026
  7. StanFromIreland
    added a commit that references this issue on Oct 19, 2026

    gh-159675: Tidy and lazify imports in `xml.sax.saxutils` (#159676)

    2dd5315
  8. StanFromIreland
    closed this as completedon Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-lazy-importstype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.