[Python-Dev] To reduce Python "application" startup time

Jelle Zijlstra jelle.zijlstra at gmail.com
Tue Sep 5 14:13:58 EDT 2017

2017-09-05 6:02 GMT-07:00 INADA Naoki <songofacandy at gmail.com>:

> Hi,
> While I can't attend to sprint, I saw etherpad and I found
> Neil Schemenauer and Eric Snow will work on startup time.
> I want to share my current knowledge about startup time.
> For bare (e.g. `python -c pass`) startup time,  I'm waiting C
> implementation of ABC.
> But application startup time is more important.  And we can improve
> them with optimize importing common stdlib.
> Current `python -v` is not useful to optimize import.
> So I use this patch to profile import time.
> https://gist.github.com/methane/e688bb31a23bcc437defcea4b815b1eb
> With this profile, I tried optimize `python -c 'import asyncio'`, logging
> and http.client.
> https://gist.github.com/methane/1ab97181e74a33592314c7619bf342
> 33#file-0-optimize-import-patch
> This patch moves a few imports inside functions. I wonder whether that
kind of change actually helps with real applications—doesn't any real
application end up importing the socket module anyway at some point?

> With this small patch:
> logging: 14.9ms -> 12.9ms
> asyncio: 62.1ms -> 58.2ms
> http.client: 43.8ms -> 36.1ms
> I haven't created pull request yet.
> (Can I create without issue, as trivial patch?)
> I'm very busy these days, maybe until December.
> But I hope this report helps people working on optimizing startup time.
> Regards,
> INADA Naoki  <songofacandy at gmail.com>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> jelle.zijlstra%40gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170905/ad4561e7/attachment.html>

More information about the Python-Dev mailing list