[Python-Dev] repr(1.1)

Holger Krekel pyth at devel.trillke.net
Tue Mar 30 18:33:40 EST 2004


Jewett, Jim J wrote:
> Ka-Ping Yee:
> 
> > In fact, you've just given a stronger reason for keeping "1.1".
> > Currently, compiling a .py file containing "1.1" produces a .pyc file
> > containing "1.1000000000000001".  .pyc files are supposed to be
> > platform-independent.  If these files are then run on a platform with
> > different floating-point precision, the .py and the .pyc will produce
> > different results.
> 
> In a previous job, every system upgrade meant a C compiler upgrade.  We 
> would recompile everything and rerun a week of production data as a 
> regression test.  We would get different results.  Then I had to find 
> each difference to let the customer decide whether it was large enough 
> to really matter.  (It never was.)
> 
> I would have been very grateful if I could have flipped a switch to say
> "Do the math like the old version, even if it was buggy.  Do it just this
> once, so that I can show the customer that any changes are intentional!"
> 
> Running a .pyc created on system1 should produce the same results you 
> got on system1, even if system2 could do a better job.  Printing a 
> dozen zeros followed by a 1 tells system2 just how precise the
> calculations should be.

This sounds more like a general versioning issue.  If you e.g. use Numeric, 
and face C-compiler and python upgrades (and what not), you can hardly expect 
python to simulate your old environment.  And .pyc files are not guaruanteed to 
work across different versions of Python (which is likely the reason why 
system2 could do a better job, anyway). 

cheers,

    holger



More information about the Python-Dev mailing list