On 4/13/2014 4:11 AM, Łukasz Langa wrote:
On Apr 13, 2014, at 12:48 AM, Stefan Behnel <stefan...@behnel.de> wrote:

Stefan Behnel, 12.04.2014 19:11:

So, what I've learned from seven years of Cython is that static typing in
signatures is actually less interesting than you might think at first
sight. It might be ok for documentation purposes, although its verboseness
makes that also a bit questionable.

You raise a valid point that type hinting a dict instead of a Mapping is
likely to create an overly limiting API. This sort of error is however
quite easy to fix forward.

To counter, we’ve had multiple data points during the summit suggesting
that duck typing is not really that often used in production code. In
other words, after initial prototyping and testing, an API of a callable
gets settled and is later used with a very limited number of types.

For public library code, where the use case is not known, apis should usually be as generic as sensible. For private library code, I can imagine that apis are and possibly even should be limited to classes actually used. There naturally is a bit of a bias here for public code.

Of course, fuzzy terms like “often”, “seldom”, and “limited” suggest
that we don’t have hard data here. That being said, there is a clear
need to improve our ability to lint code, refactor code easier, and
document the contracts better. This has been voiced by various
conference attendees and the consensus is tremendous.

This need applies to public as well as private code. Private code is a good place for experiments.

For Python specifically the existence of prototypes like Mypy, obiwan,
or pytypedecl shows that there is growing interest in standardizing this
functionality. Therefore, I'm drafting a PEP for opt-in type hints with
optional checks at runtime and by static analysis. Will post the initial
form in the upcoming days, and then we can go paint that bike shed.

I look forward to it.

I'm aware that great care here is needed for the outcome to feel
Pythonic and not overwhelming. Don't worry before you get your hands on
the draft, though.

I'm not. PEPs routinely get revised, and ofter improved, no matter the author.

--
Terry Jan Reedy


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to