time.sleep accuracy

Peter Hansen peter at engcorp.com
Mon Sep 18 23:16:11 EDT 2000


Jonadab the Unsightly One wrote:
> 
> Nick Collier <nick at src.uchicago.edu> wrote:
> 
> > I'm wondering if anyone knows how accurate time.sleep is? For example,
> > if I want to sleep for 50 milliseconds (time.sleep(.05)), what's the
> > actual margin or error? Is this os dependent?
> 
> In theory, it's hardware dependant.  But reasonably modern
> hardware should be able to get within a millisecond if the
> software is sufficiently discerning, so in practice it
> probably is not hardware dependent on modern systems.

Is the latter statement more than just theory?  I strongly doubt that
Windows, for example, would consistently come in any closer than +/- ten
or twenty milliseconds.  Maybe on a real-time operating system.

I have not had opportunity to test either way...

-- 
Peter Hansen



More information about the Python-list mailing list