This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2020-06-17.13:58:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Currently, the runpy module imports many modules. runpy is used by "python3 -m module". I propose to attempt to reduce the number of imports to reduce Python startup time.

With my local changes, I reduce Python startup time from 24 ms to 18 ms:

Mean +- std dev: [ref] 24.3 ms +- 0.2 ms -> [patch] 18.0 ms +- 0.3 ms: 1.35x faster (-26%)

Timing measured by:

  ./python -m venv env
  python -m pyperf command -v -o patch.json -- env/bin/python -m empty

Currently, runpy imports +21 modules:

* ./python Total 33
* ./python -m mod: Total 54 (+21)

Example with attached

$ ./python -m mod
Total 70
Date User Action Args
2020-06-17 13:58:21vstinnersetrecipients: + vstinner
2020-06-17 13:58:21vstinnersetmessageid: <>
2020-06-17 13:58:21vstinnerlinkissue41006 messages
2020-06-17 13:58:20vstinnercreate