I can give it floating point numbers, such as
time.sleep(0.5)
but how accurate is it? If i give it
time.sleep(0.05)
From the documentation:
On the other hand, the precision of
time()
andsleep()
is better than their Unix equivalents: times are expressed as floating point numbers,time()
returns the most accurate time available (using Unixgettimeofday
where available), andsleep()
will accept a time with a nonzero fraction (Unixselect
is used to implement this, where available).
And more specifically w.r.t. sleep()
:
Suspend execution for the given number of seconds. The argument may be a floating point number to indicate a more precise sleep time. The actual suspension time may be less than that requested because any caught signal will terminate the
sleep()
following execution of that signal’s catching routine. Also, the suspension time may be longer than requested by an arbitrary amount because of the scheduling of other activity in the system.