Skip to content

Importing pkg_resources is slow. Work is done at import time. #926

@dsully

Description

@dsully

Any "import pkg_resources" by a module is slow, in the 100-150ms range, depending on the system.

This is due to the number of modules imported by pkg_resources itself (email.parser is also slow), and side-effect work done at import time, notably the _initialize and _initialize_master_working_set functions at the bottom of pkg_resources/__init__.py.

As wall clock time matters to humans running CLIs, every millisecond counts.

The work done at import time should be deferred until needed, and the imports themselves also deferred if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions