[Python-Dev] Python startup time
Victor Stinner
victor.stinner at gmail.com
Wed Jul 19 10:26:56 EDT 2017
2017-07-19 15:22 GMT+02:00 Oleg Broytman <phd at phdru.name>:
> On Wed, Jul 19, 2017 at 02:59:52PM +0200, Victor Stinner <victor.stinner at gmail.com> wrote:
>> "Python is very slow to start on Windows 7"
>> https://stackoverflow.com/questions/29997274/python-is-very-slow-to-start-on-windows-7
>
> However hard you are going to optimize Python you cannot fix those
> "defenders", "guards" and "protectors". :-) This particular link can be
> excluded from consideration.
Sorry, I didn't read carefully each link I posted. Even for me knowing
what Python does at startup, it's hard to explain why 3 people have
different timing: 15 ms, 75 ms and 300 ms for example. In my
experience, the following things impact Python startup:
* -S option: loading or not the site module
* Paths in sys.path: PYTHONPATH environment variable for example
* .pth files files in sys.path
* Python running in a virtual environment or not
* Operating system: Python loads different modules at startup
depending on the OS. Naoki INADA just removed _osx_support from being
imported in the site module on macOS for example.
My list is likely incomplete.
In the performance benchmark suite, a controlled virtual environment
is created to have a known set of modules. FYI running Python is a
virtual environment is slower than "system" python which runs outside
a virtual environment...
Victor
More information about the Python-Dev
mailing list