[issue39484] time_ns() and time() cannot be compared on windows

Vincent Michel report at bugs.python.org
Mon Feb 3 13:40:47 EST 2020


Vincent Michel <vxgmichel at gmail.com> added the comment:

@mark.dickinson
> To be clear: the following is flawed as an accuracy test, because the *multiplication* by 1e9 introduces additional error.

Interesting, I completely missed that! 

But did you notice that the full conversion might still perform better when using only floats?

```
>>> from fractions import Fraction as F                                                   
>>> r = 1580301619906185300                                                              
>>> abs(int(r / 1e9 * 1e9) - r)                                                          
84
>>> abs(round(F(r / 10**9) * 10**9) - r)                                               
89
```

I wanted to figure out how often that happens so I updated my plotting, you can find the code and plot attached.

Notice how both methods seems to perform equally good (the difference of the absolute errors seems to average to zero). I have no idea about why that happens though.

----------
Added file: https://bugs.python.org/file48882/Comparing_conversions_over_5_us.png

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39484>
_______________________________________


More information about the Python-bugs-list mailing list