[Python-bugs-list] [ python-Bugs-422177 ] Results from .pyc differs from .py

noreply@sourceforge.net noreply@sourceforge.net
Mon, 07 May 2001 18:09:56 -0700


Bugs item #422177, was updated on 2001-05-07 18:09
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=422177&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 7
Submitted By: Tim Peters (tim_one)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Results from .pyc differs from .py

Initial Comment:
Guido, the following is from c.l.py.  It *seems* to be 
due to marshal using damagingly low precision for 
float->string conversion.  If you don't object to my 
fixing it, assign this back to me.  But I'll still be 
baffled by why the .py result differs from the .pyc 
result (which I reproduced under current CVS, under 
Windows):


-----Original Message-----
From: python-list-admin@python.org
On Behalf Of Scott Ransom
Sent: Monday, May 07, 2001 4:27 PM
To: python-list@python.org
Cc: Scott Ransom
Subject: Variables different between .py and .pyc


Hello,

I'm running Python 2.0 on Linux and seem to have found
a strange problem when importing floating point
variables defined in modules.  I have not
tried this in Python 2.1 so I don't know if the
problem exists there as well.

Here is a simple module (vars.py):

PI    = 3.14159265358979324
TWOPI = 6.28318530717958648

When I import this and check the variable values here
is what I get:

presto:~$ python
Python 2.0 (#6, Nov 16 2000, 12:32:08)
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "copyright", "credits" or "license" for more 
information.
>>> import vars
>>> vars.PI, vars.TWOPI
(3.1415926535897931, 6.2831853071795862)

All is well, so far.  Now, if I try again (and this
time the interpreter loads from the newly created
vars.pyc file):

presto:~$ python
Python 2.0 (#6, Nov 16 2000, 12:32:08)
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "copyright", "credits" or "license" for more 
information.
>>> import vars
>>> vars.PI, vars.TWOPI
(3.1415926535900001, 6.2831853071800001)

My variables are truncated at ~12 decimal points of
precision.

Removing the .pyc file makes things "better" again...

presto:~$ rm vars.pyc
presto:~$ python
Python 2.0 (#6, Nov 16 2000, 12:32:08)
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "copyright", "credits" or "license" for more 
information.
>>> import vars
>>> vars.PI, vars.TWOPI
(3.1415926535897931, 6.2831853071795862)

...


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=422177&group_id=5470