Starting from Python 3.7 we have new time functions supporting nanosecond resolution. However, I am not sure how time.time_ns() is supposed to work.
Look at the following example:
>>> for n in range(10):
... time.sleep(random.random())
... print((time.time(), time.time_ns(), time.monotonic_ns()))
...
(1545306865.8667252, 1545306865866727000, 439497985080)
(1545306866.084973, 1545306866084974000, 439716229679)
(1545306866.2972622, 1545306866297264000, 439928562751)
(1545306866.635714, 1545306866635716000, 440267014751)
(1545306866.745001, 1545306866745003000, 440376301646)
(1545306867.212074, 1545306867212076000, 440843415181)
(1545306867.7111092, 1545306867711111000, 441342449470)
(1545306867.792372, 1545306867792374000, 441423713091)
(1545306867.821886, 1545306867821887000, 441453223973)
(1545306868.127483, 1545306868127485000, 441758824065)
As you can see, time.time_ns() does return time as an integer with nanosecond precision, but the last digits are always 000. Which should not be the case. Is it a bug or am I missing something?