Type signature

hanumizzle at gmail.com hanumizzle at gmail.com
Sat Jul 22 18:38:38 EDT 2006


Yacao Wang wrote:
> Hi, I'm a newbie to Python. I've recently read some books about this
> language and none of them have answered my question.
> As a dynamically-typed language Python doesn't need any form of type
> signature which makes the syntax very clean and concise.

OK...

> However, type
> signatures are not only a kind of information provided for the compiler

Statically-typed code tends (generally) to be faster than
dynamically-typed code, obviously. Often, it doesn't really matter,
though. (This is an old argument.)

Lush is an interesting Lisp-like language that supports admixture of
dynamic and static typing, and uses type signatures to support it. It
can produce high performance machine code because of this.

> Python relies too much on run-time type-checking, that is,
> whenever you give the wrong type, you just end up with an exception, which
> is logically correct, but not that useful as type signatures.

As said before, polymorphism plays an important role. In addition to
looking up 'duck typing' (c.f. Programming Ruby), it might also be
useful to look for Damian Conway's observations on 'interface
polymorphism' (standard practice in Perl, Python, Ruby, etc.) vs.
'inheritance polymorphism' (what you get with C++ and IIRC Java).




More information about the Python-list mailing list