pypa / pypa/setuptools

[BUG] Importing `setuptools` is slow and takes nearly half a second

Open
#3,441 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools version

63.1.0

Python version

3.10.5

OS

Windows

Additional environment information

No response

Description

Importing setuptools is slow and takes nearly half a second. This imposes significant performance impact on CLI applications (https://github.com/Azure/azure-cli/issues/23177).

Expected behavior

Importing setuptools should be fast.

How to Reproduce
import setuptools
Output
python -X importtime -c "import setuptools" 2>perf.log ; python -m tuna .\perf.log

image

Without setuptools, importing distutils is pretty fast:

python -X importtime -c "import distutils" 2>perf.log ; python -m tuna .\perf.log

image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Windows case with python -X importtime -c "import setuptools" and inspect the resulting perf.log with python -m tuna. The issue names no source files or tests; done means identifying and reducing the import-time overhead while preserving the existing setuptools import behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.