[Python-ideas] Proposal: Use mypy syntax for function annotations

Juancarlo Añez apalala at gmail.com
Thu Aug 14 16:59:54 CEST 2014


On Wed, Aug 13, 2014 at 3:14 PM, Guido van Rossum <guido at python.org> wrote:

> I am proposing that we adopt whatever mypy uses here, keeping discussion
> of the details (mostly) out of the PEP. The goal is to make it possible to
> add type checking annotations to 3rd party modules (and even to the stdlib)
> while allowing unaltered execution of the program by the (unmodified)
> Python 3.5 interpreter.


To the bottom of things...

About the second time I wrote about Python ("Why not Python", 2007) I
dismissed it as serious software development environment because the lack
of static type checking hindered the creation of proper software
development environments.

http://blog.neogeny.org/why-not-python.html

So, Why do I now have doubts about adding support for static type checking?

I've been programming in almost-only Python for several years now, and this
discussion had me think hard about "Why?".

The answer is simple: I never was as productive as I've been since I've
centered on Python.

But, again Why?

Despite what my '07 article says, the IDE I use is pythonized-VIM and the
command line. Where does the productivity come from?

   1. Readability with the right amount of succinctness. Python programs
   are very small, but understandable.
   2. The breadth and design consistency of the standard library. Some 70%?
   of what I need is there, and the design consistency makes it easy
   (intiutive) to use.
   3. PyPi covers another 28%.
   4. The Zen of Python (import this) permeates all of the above, including
   most third-party packages. The ecosystem is consistent too. It's a culture.

What do I fear? I think it is that Python be transformed into a programming
language different from the one that now makes me so productive.

I studied Ruby, and I don't like it. I've been studying Go, and I don't
like it. One must like the concepts and the power, sure, but the syntax
required for some day-to-day stuff stinks like trouble;  simple stuff is so
complicated to express and so easy to get wrong...

I hate "List[str]" and "Dict[str:int]". Where did those come from?
Shouldn't they (as others have proposed) be "[str]" and "{str:int}"? What
about tuples?
Why not write a similar, but different programming language that targets
the Cython runtime and includes all the desired features?

All said, this is my proposal.

The PSF could support (even fund) MyPy and similar projects, promoting
their maturity and their convergence. The changes in 3.5 would be limited
but enough to enable those efforts, and those of the several IDE
tool-smiths (changes in annotations, and maybe in ABCs). Basically, treat
MyPy as PyPy or NumPy (which got '::'). It's in Python's history to enable
third-party developments and then adopt what's mature or become the
de-facto standard.
Then, on a separate line of work, it would be good to think about how to
enable different programming languages to target the CPython environment
(because of #2, #3, and #4 above), maybe by improving AST creation and
AST-to-bytecode? There could be other languages targeting the CPython
runtime, which is the relationship that Scala, Jython, IronPython, and
others have to their own runtimes.

-1 for standardizing static type checking in 3.5

Cheers,

-- 
Juancarlo *Añez*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140814/5f6dce8f/attachment.html>


More information about the Python-ideas mailing list