This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients larry, lemburg, mark.dickinson, rhettinger, serhiy.storchaka, stutzbach, vstinner, vxgmichel
Date 2020-02-03.14:47:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580741276.57.0.650220493874.issue39484@roundup.psfhosted.org>
In-reply-to
Content
I'm not sure which kind of problem you are trying to solve here. time.time() does lose precision because it uses the float type. Comparing time.time() and time.time_ns() tricky because of that. If you care of nanosecond precision, avoid float whenever possible and only store time as integer.

I'm not sure how to compat time.time() float with time.time_ns(). Maybe math.isclose() can help.

I don't think that Python is wrong here, time.time() and time.time_ns() work are expected, and I don't think that time.time() result can be magically more accurate: 1580301619906185300 nanoseconds (int) cannot be stored exactly as floating point number of seconds.

I suggest to only document in time.time() is less accurate than time.time_ns().
History
Date User Action Args
2020-02-03 14:47:56vstinnersetrecipients: + vstinner, lemburg, rhettinger, mark.dickinson, larry, stutzbach, serhiy.storchaka, vxgmichel
2020-02-03 14:47:56vstinnersetmessageid: <1580741276.57.0.650220493874.issue39484@roundup.psfhosted.org>
2020-02-03 14:47:56vstinnerlinkissue39484 messages
2020-02-03 14:47:56vstinnercreate