[Python-Dev] Store startup modules as C structures for 20%+ startup speed improvement?

Jeethu Rao jeethu at jeethurao.com
Fri Sep 21 03:19:18 EDT 2018


> On Sep 21, 2018, at 06:53, Stefan Behnel <stefan_ml at behnel.de> wrote:
> 
> Totally. This might actually be more relevant for Cython than for CPython
> in the end, because it wouldn't be limited to the stdlib and its core modules.
> 
> It's a bit more difficult for us, because this probably won't work easily
> across Python releases (2.[67] and 3.[45678] for now) and also definitely
> not for PyPy, but that just means some multiplication of the generated
> code, and we have the dynamic part of it already. Supporting that for
> Unicode strings will be fun, I'm sure. :)

I’m glad to hear that this might be relevant to Cython.
I believe it should be straightforward to parametrize the code generator to generate code targeted
at specific cPython versions. While we originally targeted 3.6, Larry Hastings managed to quickly port it to 3.8.
The two changes in cPython’s data structures between 3.6 and 3.8 that needed changes to the
code-gen were [1] from 3.7 and [2] from 3.8. And internally, I’ve still got a task open to back-port this to support 2.7.

-- Jeethu

[1]: https://bugs.python.org/issue18896
[2]: https://bugs.python.org/issue33597


More information about the Python-Dev mailing list