[Python-Dev] Language Summit notes

Stefan Behnel stefan_ml at behnel.de
Sat Apr 12 19:11:36 CEST 2014


Guido van Rossum, 10.04.2014 03:08:
> - Jukka Lehtosalo gave a talk and answered questions about mypy, his design
> and implementation of pragmatic type annotations (no new syntax required,
> uses Python 3 function annotations).

FWIW, signature type annotations aren't enough for a static compiler like
Cython, which also benefits from local and global variable declarations,
static functions, etc. However, we initially discussed this feature in the
project some five years ago or so and never actually implemented it, so I
finally decided to add support for it to Cython. There already was a way to
provide static Cython/C type declarations in pure Python code, also for
function arguments, but it's nice to have a way that is also naturally
runtime inspectable in the signature.

It essentially looks like this now:

    def func(plain_python_type: dict,
             named_python_type: 'list',
             explicit_python_type: {'type': dict},
             explicit_named_python_type: {'type': 'tuple'},
             explicit_c_type: {'ctype': 'int'}):
        ...

Pretty straight forward, I think.

Stefan




More information about the Python-Dev mailing list