[pypy-svn] pypy default: Small optimization in round() for the usual case

amauryfa commits-noreply at bitbucket.org
Mon Feb 14 18:31:20 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r41917:5b6bd0574016
Date: 2011-02-14 18:22 +0100
http://bitbucket.org/pypy/pypy/changeset/5b6bd0574016/

Log:	Small optimization in round() for the usual case

diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -730,9 +730,8 @@
         # round to a decimal string; use an extra place for halfway case
         strvalue = formatd(value, 'f', ndigits + halfway_case)
 
-        buf = [c for c in strvalue]
-
         if halfway_case:
+            buf = [c for c in strvalue]
             if ndigits >= 0:
                 endpos = len(buf) - 1
             else:


More information about the Pypy-commit mailing list