So I was looking for a more precise alternative to time.sleep()
in Python but couldn't find any good options. Does anyone know if there is a more accurate alternative with at least millisecond precision?
Something like this:
precise_delay(3.141)
# Pauses the program for exactly 3.141 seconds
And no, I tried, and time.sleep()
is not very precise.
I did some testing using time.perf_counter()
and the results varied from 0.005
to 0.015
even tho I entered 0.001
.
Here are the precise times:
0.013264300000628282
, 0.005171099999643047
and 0.015634399999726156