[Python-Dev] Python startup time

Christian Heimes christian at python.org
Thu Oct 10 14:25:18 CEST 2013


Am 10.10.2013 06:41, schrieb yoav glazner:
> I'm not sure Droping imports is the best way to go, since every python
> script/app will import common modules right on the start and it will
> still seem like the interpeter boot is slow.
> 
> making modules load faster seems like a better approch

Not every script uses the re or collections module. Especially short
running and simple Python programs suffer from import overuse. Every
imported module adds extra syscalls and IO, too. These are costly
operations, especially on slow or embedded devices.


Benchmark of 1000 times "python -c ''"

Python 3.4dev with all my experimental patches:

  Avg: 0.705161 -> 0.443613: 1.59x faster

2.7 -> 3.4dev:

  Avg: 0.316177 -> 0.669330: 2.12x slower

2.7 -> 3.4dev with all my patches:

  Avg: 0.314879 -> 0.449556: 1.43x slower

http://pastebin.com/NFrpa7Jh

Ain't bad! The benchmarks were conducted on a fast 8 core machine with SSD.

Christian




More information about the Python-Dev mailing list