Static typing
Bruno Desthuilliers
bdesth.nospam at removeme.free.fr
Sun Jul 27 18:10:45 EDT 2003
Tayss wrote:
> Bruno Desthuilliers <bdesth.nospam at removeme.free.fr> wrote in message news:<3f23ae06$0$21093$626a54ce at news.free.fr>...
>
>>>FWIW, I do favor the addition of optional static typing for the two
>>>reasons Scott described - interface documentation and optimization.
>>
>>Interface documentation may be obtained in others ways (docstring for
>>exemple).
>
>
> Indeed! As I remember, Jython uses doc strings for typing, when it
> presents an API to Java. So it's in the comments, and I think that's
> an oddly appropriate place for hints to the compiler.
In CPython, it is not supposed to be a hint to the compiler, it's
supposed to be API documentation for the programmer.
>>And I'm not sure static typing would optimize anything, but
>>not being a Python (nor anything else) guru, I would not bet my hand on
>>this...
>
>
> If you mess around with lisp, you can easily see the compiled assembly
> language of your functions when you experiment with optional typing.
> (By calling the function "disassemble".) Normally, the compiler spews
> a lot of general code because it doesn't know what you've passed in.
> But when you promise that you're passing in numbers or something, the
> assembly language is much tighter.
Lisp is not Python. I was talking about static typing 'optimizing'
anything in Python.
> Sort of like when someone asks you to move something to a different
> house, and you have no idea how big it is. If you were told, "It's
> just a pillow," you know that you don't need to order a huge truck or
> take any special precautions.
Err... Given the actual speed and cost of a decent PC processor, I'm not
willing to trade my time for a few milliseconds. And if I really need to
have a really fast code, I know where my C compiler is !-)
Bruno
More information about the Python-list
mailing list