[issue39484] time_ns() and time() cannot be compared on windows
STINNER Victor
report at bugs.python.org
Mon Feb 3 11:35:12 EST 2020
STINNER Victor <vstinner at python.org> added the comment:
I compare nanoseconds (int):
>>> t=1580301619906185300
# int/int: int.__truediv__(int)
>>> abs(t - int(t/10**9 * 1e9))
172
# int/float: float.__rtruediv__(int)
>>> abs(t - int(t/1e9 * 1e9))
84
# float/int: float.__truediv__(int)
>>> abs(t - int(float(t)/10**9 * 1e9))
84
# float/float: float.__truediv__(float)
>>> abs(t - int(float(t)/1e9 * 1e9))
84
=> int/int is less accurate than float/float for t=1580301619906185300
You compare seconds (float/Fraction):
>>> from fractions import Fraction as F
>>> t=1580301619906185300
# int / int
>>> float(F(t/10**9) * 10**9 - t)
88.5650634765625
# int / float
>>> float(F(t/1e9) * 10**9 - t)
-149.853515625
=> here int/int looks more accurate than int/float
And we get different conclusion :-)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39484>
_______________________________________
More information about the Python-bugs-list
mailing list