[Python-Dev] Type hints -- a mediocre programmer's reaction (original) (raw)

Daniel Holth dholth at gmail.com
Thu Apr 23 16:12:04 CEST 2015


On Thu, Apr 23, 2015 at 9:55 AM, Paul Sokolovsky <pmiscml at gmail.com> wrote:

Hello,

On Thu, 23 Apr 2015 09:15:44 -0400 Daniel Holth <dholth at gmail.com> wrote: []

>> Also ask why no one used type specifier, they are possible since >> Python 3.0 ? >> Because it is the wrong way for Python. > > That's an example of how perceptions differ. In my list, everyone(*) > uses them - MyPy, MicroPython, etc. Even more should use them (any > JIT module, which are many), but sit in the bushes, waiting for a > kick, like PEP484 provides.

It's OK that type hints are only to assist the programmer. Yes, it's OK to have a situation where type hints assist only a programmer. It's not OK to think that type hints may be useful only for programmer, instead of bunch more purposes, several of which were already shown in the long previous discussion. PyPy's FAQ has an explanation of why type hints are not for performance. http://pypy.readthedocs.org/en/latest/faq.html#would-type-annotations-help-pypy-s-performance You probably intended to write "why type hints are not for PyPy's performance". There're many other language implementations and modules for which it may be useful, please don't limit your imagination by a single case. And speaking of PyPy, it really should think how to improve its performance - not of generated programs, but of generation itself. If compilation of a trivial program on a pumpy hardware takes 5 minutes and gigabytes of RAM and diskspace, few people will use it for other purposes beyond curiosity. There's something very un-Pythonic in waiting 5 mins just to run 10-line script. Type hints can help here too ;-) (by not wasting resources propagating types thru the same old standard library for example).

Naturally, PyPy is very controversial.

Type annotations can help to compile Python into a subset of Python.



More information about the Python-Dev mailing list