[Python-Dev] Type hints -- a mediocre programmer's reaction

Guido van Rossum guido at python.org
Tue Apr 21 18:59:50 CEST 2015


On Tue, Apr 21, 2015 at 7:51 AM, Cory Benfield <cory at lukasa.co.uk> wrote:

> The correct specification is "read method with this type signature"
> and "seek method with this type signature". I would even be prepared
> to waive the type signatures on read and seek, given that enforcing
> the type hinting on others is not a good idea.
>
> I suspect I have a mismatch with several others in this discussion. My
> position is that if I'm going to have a type system, I'd like to have
> a powerful one: Haskell, not Java. Otherwise I'll get by with the duck
> typing that has worked just fine for us over the last 20 years. I
> suspect, however, that many others in this conversation want any type
> system at all, so long as they can have one.
>

For me, PEP 484 is a stepping stone. Among the authors of PEP 484 there was
much discussion about duck typing, and mypy even has some limited support
for duck typing (I think you can still find it by searching the mypy code
for "protocol"). But we ran out of time getting all the details written up
and agreed upon, so we decided to punt -- for now. But duck typing still
needs to have a way to talk about things like "seek method with this type
signature" (something like `def seek(self, offset: int, whence:
int=SEEK_SET) -> int`) so the current proposal gets us part of the way
there.

The hope is that once 3.5 is out (with PEP 484's typing.py included
*provisional* mode) we can start working on the duck typing specification.
The alternative would have been to wait until 3.6, but we didn't think that
there would be much of an advantage to postponing the more basic type
hinting syntax (it would be like refusing to include "import" until you've
sorted out packages). During the run of 3.5 we'll hopefully get feedback on
where duck typing is most needed and how to specify it -- valuable input
that would be much harder to obtain of *no* part of the type hints notation
were standardized.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150421/b148d9f3/attachment.html>


More information about the Python-Dev mailing list