
Ask HN: Do you need to work at a ns precision? - scared2
I just saw that python datetime 64 default setting is at a ns scale. I just wonder how many people actually need that setting.
======
mytailorisrich
Most CPUs run at > 1GHz these days so 1ns is already not precise enough to
count cycles, but is small enough that it will be fine for the vast majority
of use cases. If you need picosecond accuracy you are probably doing something
that requires special hardware anyway.

These other aspect is that 64 bits allow such a huge interval that it makes
sense to use it. Even counting in nanoseconds increments this allows for a
monotonic counter to run over literally hundreds of years.

So 64 bits in increments of 1ns (or close to) is both doable on most modern
hardware and allows for the vast majority of use cases for decades to come (if
not longer) without have to think about changing it again and again.

------
easytiger
Worked for many years measuring and instrumenting systems at the nanosecond
levels on Linux.

Windows is generally not considered viable for work at that level. Other Unix
I've not used in that fashion sadly.

The python datetimes just wrap Linux calls to clock_gettime() to populate a
timespec. On 32bit that is a syscall but on 64bit it is a VDSO, thus costs
mostly just a memory access and avoids stack swap. (so very fast)

If you are using it to measure anything reliably you need a fairly solid ptp
time infrastructure or it is pointless

