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 mark.dickinson
Recipients Arfrever, Eli_B, Niklas.Claesson, Ramchandra Apte, andrewclegg, anglister, belopolsky, giampaolo.rodola, goshawk, lemburg, mark.dickinson, mdcb808@gmail.com, p-ganssle, python-dev, pythonhacker, r.david.murray, scoobydoo, serhiy.storchaka, tim.peters, tomikyos
Date 2021-04-30.11:20:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1619781636.36.0.120237134572.issue15443@roundup.psfhosted.org>
In-reply-to
Content
[Alexander]

> Is there high enough demand for nanoseconds in datetime and time instances?

One need that we've encountered in real code is simply for compatibility. We have Python code that interacts with a logging web service whose timestamps include nanosecond information. Whether or not nanosecond resolution makes sense for those timestamps is a moot point: that's out of our control.

When representing information retrieved from that web service in Python-land, we have a problem. If datetime.datetime had nanosecond precision, then using datetime.datetime to represent the retrieved values would be a no-brainer. As it is, we face a choice between:

- truncating or rounding to microsecond precision, and losing information as a result (which is particularly problematic if we want to write records back at any point)
- representing in some indirect form (as a str, an integer number of nanoseconds, a (datetime, nanoseconds) tuple, ...) and requiring the user to convert values for plotting or other analysis
- writing our own non-standard ns-supporting datetime class, or looking for a 3rd party library with that support

None of those choices are terrible, but none of them are particularly palatable compared with using a standard library solution. (FWIW, we went with option 2, returning nanoseconds since the Unix epoch as an int.)
History
Date User Action Args
2021-04-30 11:20:36mark.dickinsonsetrecipients: + mark.dickinson, lemburg, tim.peters, belopolsky, giampaolo.rodola, pythonhacker, Arfrever, r.david.murray, andrewclegg, python-dev, Ramchandra Apte, Eli_B, serhiy.storchaka, goshawk, Niklas.Claesson, mdcb808@gmail.com, scoobydoo, tomikyos, p-ganssle, anglister
2021-04-30 11:20:36mark.dickinsonsetmessageid: <1619781636.36.0.120237134572.issue15443@roundup.psfhosted.org>
2021-04-30 11:20:36mark.dickinsonlinkissue15443 messages
2021-04-30 11:20:36mark.dickinsoncreate