optional static typing for Python

John Nagle nagle at animats.com
Mon Jan 28 11:31:43 EST 2008


Arnaud Delobelle wrote:
> On Jan 27, 11:00 pm, "Russ P." <Russ.Paie... at gmail.com> wrote:
>> On Jan 27, 2:49 pm, "André" <andre.robe... at gmail.com> wrote:
>>> Perhaps this:http://www.python.org/dev/peps/pep-3107/mightbe
>>> relevant?
>>> André
>> Thanks. If I read this correctly, this PEP is on track for Python 3.0.
>> Wonderful!
> 
> Note that annotations do not provide explicit typing, AFAIK:
> 
> def f(x:int) -> int: return x*2
> 
> is stricly equivalent to
> 
> def f(x): return x*2
> f.__annotations__ = {'x':int, 'return':int}
> 
> You still need to write a type-checking wrapper. 

    Unenforced static typing is somewhat pointless.  If that
goes in, it should be enforced by implementations.  Otherwise,
maintenance programmers can't trust the type information they see.

    Enforced, it makes it possible to start getting serious about
optimizing compilers for Python, like Shed Skin.  Shed Skin
can usually figure out typing within a module, but across module
boundaries, some help is needed if you want to push optimization from
run time to compile time.

				John Nagle



More information about the Python-list mailing list