Fun with numbers - dammit, but I want a cast!

Erik Max Francis max at alcyone.com
Tue Aug 12 05:05:10 CEST 2003


Bengt Richter wrote:

> <nit>With (float) 1 it can optimize to one instruction with immediate
> operand constant. With the other it needs (at least on x86) to move
> via
> EAX, for two instructions (e.g., assigning the resp values).

This is wholly an implementation detail.  The point is, in C and C++,
casts have different purposes.  Some are compile-time, some are
run-time; some are safe and are simply conversion, others are unsafe and
result in implementation-defined or undefined behavior.  Not all C casts
are unsafe; some simply invoke conversions.

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Come not between the dragon and his wrath.
\__/  King Lear (Act I, Scene I)




More information about the Python-list mailing list