Skip to content

Optimize logging package import overhead with lazy imports #156777

Description

@brittanyrey

import logging.config costs ~29 ms and import logging.handlers ~26 ms, but most of what they
import is only needed conditionally based on feature usage (socket/HTTP/SMTP
handlers, the config socket listener, multiprocessing queue detection).

Apply lazy imports to the modules within the logging package while preserving finalization and shutdown expectations.

(PR is already prepared)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions