[pypy-commit] pypy default: Review 47e0578e9553: simplify float to int conversion
rlamy
pypy.commits at gmail.com
Thu Jul 28 11:24:52 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r85893:2f4ea8684a23
Date: 2016-07-28 16:24 +0100
http://bitbucket.org/pypy/pypy/changeset/2f4ea8684a23/
Log: Review 47e0578e9553: simplify float to int conversion
diff --git a/pypy/module/thread/os_lock.py b/pypy/module/thread/os_lock.py
--- a/pypy/module/thread/os_lock.py
+++ b/pypy/module/thread/os_lock.py
@@ -26,8 +26,7 @@
elif timeout == -1.0:
microseconds = -1
else:
- # 0.0 => 0.0, but otherwise tends to round up
- timeout = timeout * 1e6 + 0.999
+ timeout *= 1e6
try:
microseconds = ovfcheck_float_to_longlong(timeout)
except OverflowError:
diff --git a/pypy/module/thread/test/test_lock.py b/pypy/module/thread/test/test_lock.py
--- a/pypy/module/thread/test/test_lock.py
+++ b/pypy/module/thread/test/test_lock.py
@@ -81,7 +81,7 @@
else:
got_ovf = False
lock.release()
- assert (i, got_ovf) == (i, int(timeout * 1e6 + 0.999) > maxint)
+ assert (i, got_ovf) == (i, int(timeout * 1e6) > maxint)
@py.test.mark.xfail(machine()=='s390x', reason='may fail under heavy load')
def test_ping_pong(self):
More information about the pypy-commit
mailing list