[Python-Dev] Revive the types sig?

Paul Moore gustav at morpheus.demon.co.uk
Tue Mar 13 22:31:47 CET 2001


On Mon, 12 Mar 2001 18:15:15 -0500, barry at digicool.com (Barry A. Warsaw) wrote:
>>>>>> "UO" == Uche Ogbuji <uche.ogbuji at fourthought.com> writes:
>
>    UO> I know this isn't the types SIG and all, but since it has come
>    UO> up here, I'd like to (once again) express my violent
>    UO> disagreement with the efforts to add static typing to Python.
>    UO> After this, I won't pursue the thread further here.
>
>Thank you Uche!  I couldn't agree more, and will also try to follow
>your example, at least until we see much more concrete proposals from
>the types-sig.

My view on all this is that type annotations are likely to be counterproductive,
in the face of Python's high degree of polymorphism. For example, what is the
type of

def fac(n):
    if n <= 1: return 1
    return n * fac(n-1)

?

Obvious answer, integer -> integer. And that's likely what the programmer would
say.

But why can't this function be used with *any* type which supports comparison
with the number 1, multiplication, and subtraction of 1?

In this case, any type signature (at least, any one which is specified by the
programmer) is likely to *limit* the usability of the function, instead of
helping.

Avoiding this sort of unintended restrictiveness is likely to be hard without
type deduction technology, which I believe is a way beyond what is being
proposed...

Paul



More information about the Python-list mailing list