Python from Wise Guy's Viewpoint

Matthew Danish mdanish at andrew.cmu.edu
Wed Oct 29 03:56:04 EST 2003


On Wed, Oct 29, 2003 at 04:20:01AM +0000, Matthias Blume wrote:
> It is more than enough evidence that there are programs which require
> cycle-level efficiency and therefore cannot afford to use infinite
> precision arithmetic.

Said programs will then use specialized data types.

> It is, in my opinion, ridiculous to claim that most programs should
> use infinite precision integers in almost all places (i.e., by
> default).  Infinite precision is rarely necessary and almost always
> wasteful overkill.

How is it wasteful?  Numbers can still be represented by the most
efficient representation available, while retaining infinite precision
when operated upon.  Do you realize that Common Lisp implementations
represent integers in the range of a fixnum as machine words?  And
automatically convert them to bignum objects when they overflow?
Declarations can take this further, such that a compiler as smart as
CMUCL can manipulate raw (unsigned-byte 32) values, for example.

Are the vast majority of your programs the type which behave properly
within machine-word integers?  Do they take into account the possibility
of overflow?  Should someone have to worry about issues like overflow
when they just want to write a simple arithmetic program, in a high
level language?

> idea that the only correct result of 20 * 30 has to be 600.)

(20 * 30) mod 256 is, of course, a completely different expression.

-- 
; Matthew Danish <mdanish at andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."




More information about the Python-list mailing list