[Python-Dev] Investigating Python memory footprint of one real Web application

INADA Naoki songofacandy at gmail.com
Tue Jan 24 02:02:22 EST 2017


>> So basically the equivalent of -OO for docstrings? Maybe this can be the final motivator for some of us to come up with a design to generalize -O or something as it keeps coming up.
> Yes, please. We've talked about generalizing this for years now. FWIW, I know of projects that run with -OO for the memory wins stemming from docstrings and had to codemod assert statements into a "prod_assert" function call to achieve this. If you think docstrings aren't that much, multiply this by a few hundred processes on a box and it ends up being a substantial win to strip them out.

Strong +1.


> So far Guido blocked this on a legitimate question: how much do type hints actually cost? Nobody knows yet,

"Nobody knows yet" is difficult problem.

We may think "let's keep runtime cost, because nobody knows how large it is".
Users may think "let's use string/comment form annotation to avoid runtime cost,
because nobody knows how large it is."

And problem may happen in closed source application.
When building closed source application, the project can drop Python 2
support easily,
and buy PyCharm for all members.

(BTW, PyCharm's survey result [1] is very encouraging.
PyCharm users adopts Python 3 (relative) early.  I think they will
adopt typing early too.)

Early and large adopters of typing may be such teams (like my company).
And they may feel "Python is slow and fat!" if there are no easy way to check
runtime overhead of typing.

Optimize option to drop annotation will provide (1) easy way to check
runtime overhead of typing,
and (2) straightforward solution to remove the overhead, if it isn't negligible.


[1]: https://www.jetbrains.com/pycharm/python-developers-survey-2016/


More information about the Python-Dev mailing list