Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 61dff2b

Browse files
committed
Blurb about the increased precision of float literals in .pyc/.pyo files.
1 parent 72f98e9 commit 61dff2b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Misc/NEWS

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@ What's New in Python 2.2a0?
33

44
Core
55

6+
- Float (and complex) literals in source code were evaluated to full
7+
precision only when running from a .py file; the same code loaded from a
8+
.pyc (or .pyo) file could suffer numeric differences starting at about the
9+
12th significant decimal digit. For example, on a machine with IEEE-754
10+
floating arithmetic,
11+
12+
x = 9007199254740992.0
13+
print long(x)
14+
15+
printed 9007199254740992 if run directly from .py, but 9007199254740000
16+
if from a compiled (.pyc or .pyo) file. This was due to marshal using
17+
str(float) instead of repr(float) when building code objects. marshal
18+
now uses repr(float) instead, which should reproduce floats to full
19+
machine precision (assuming the platform C float<->string I/O conversion
20+
functions are of good quality).
21+
22+
This may cause floating-point results to change in some cases, and
23+
usually for the better, but may also cause numerically unstable
24+
algorithms to break.
25+
626
- Dictionary objects now support the "in" operator: "x in dict" means
727
the same as dict.has_key(x).
828

0 commit comments

Comments
 (0)