Python from Wise Guy's Viewpoint

Fergus Henderson fjh at cs.mu.oz.au
Thu Oct 30 00:19:51 EST 2003


Pascal Bourguignon <spam at thalassa.informatimago.com> writes:

>Matthias Blume <find at my.address.elsewhere> writes:
>
>> Pascal Costanza <costanza at web.de> writes:
>> 
>> > Computers are fast enough and have enough memory nowadays. You are
>> > talking about micro efficiency. That's not interesting anymore.
>> 
>> I have worked on projects where people worried about *every cycle*.
>> (Most of the time I agree with you, though.  Still, using infinite
>> precision by default is, IMO, a mistake. 
>
>What  are you  writing about?  Figments  of your  imagination or  real
>concrete systems?

He is talking about real concrete systems, e.g. Haskell or Lisp.

>Where do you see "infinite precision by default" [in Lisp]?

We know that implementations of dynamically typed languages such as Lisp
represent small integers efficiently.  So do good implementations of
statically typed languages in which arbitrary precision arithmetic is
the default.  But in both cases, these implementations pay a price --
compared to statically typed languages using fixed precision arithmetic --
because of the possibility that adding two unknown word-sized values
may generate a result which no longer fits in a single word.  The compiler
needs to generate extra code to cater for that possibility.  Then in turn,
each subsequent operation needs to cater for the possibility that the input
will not fit in a word.  The extra tests slow the code down, and the
extra code size reduces locality.

In a dynamically typed language, this price is normally not considered
to be much of an issue, because it has already been paid for up-front:
the cost is just the same cost as you would normally for pay for *every*
data access in a dynamically typed language.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.




More information about the Python-list mailing list