PEP 3107 and stronger typing (note: probably a newbie question)

Eduardo "EdCrypt" O. Padoan eopadoan at altavix.com
Fri Jun 22 15:35:04 EDT 2007


On 6/22/07, John Nagle <nagle at animats.com> wrote:
> Paul Boddie wrote:
> > P.S. I agree with the sentiment that the annotations feature of Python
> > 3000 seems like a lot of baggage. Aside from some benefits around
> > writing C/C++/Java wrappers, it's the lowest common denominator type
> > annotation dialect that dare not be known as such, resulting from a
> > lack of consensus about what such a dialect should really do, haunted
> > by a justified fear of restrictive side-effects imposed by a more
> > ambitious dialect (eg. stuff you get in functional languages) on
> > dynamically-typed code. I don't think the language should be modified
> > in ways that only provide partial, speculative answers to certain
> > problems when there's plenty of related activity going on elsewhere
> > that's likely to provide more complete, proven answers to those
> > problems.
>
>      I agree.  It's a wierd addition to the language.  It looks like
> a compromise between the "no declarations" position and the "make
> the language strongly typed" position.  But it's so ill-defined that
> it's not helpful, and worse than either extreme.  The whole
> approach is antithetical to the "only one way to do it" concept.
> This could lead to misery when different libraries use
> incompatible type annotation systems, which is not going to be fun.
>
>      Python made it this far without declarations, and programmers
> seem to like that.  We need to get Python performance up, and
> the ShedSkin/Psyco restrictions seem to be enough to allow that.
> Type annotations don't seem to solve any problem that really needs
> to be solved.
>
>      The main advantage of strongly typed systems is that more errors
> are detected at compile time.  You pay for this in additional language
> baggage.  PEP 3107 adds the excess baggage without providing the benefit
> of compile time checks.

Remember that pure CPython has no different "compile time" and
runtiime. But Psyco and ShedSkin could use the annotations the way
they want.

Function annotations, as PEP 3107 says, just adds "arbitrary metadata
annotations to Python functions" - If you follow the py-dev discutions
about it, it was only accepted because it have more possible uses then
just type checking. Also, there are many approches and different needs
for type checking/restrictions ("safety", IDEs autocompletion hints,
performance... )
So the annotations will be more a "signature documentation", so
different libraries can do whatever it want of it - I problably will
use only as documentation, like in:

def compile(source: "something compilable",
           filename: "where the compilable thing comes from",
           mode: "is this a single statement or a suite?"):


-- 
EduardoOPadoan (eopadoan->altavix::com)
Bookmarks: http://del.icio.us/edcrypt



More information about the Python-list mailing list