[Tutor] better resolution on time.sleep()?

Roger Merchberger zmerch at 30below.com
Tue May 24 01:56:14 CEST 2005


Rumor has it that jfouhy at paradise.net.nz may have mentioned these words:
>Quoting Roger Merchberger <zmerch at 30below.com>:
>
> > I really only need between 500 and 1000 samples per second, but as the
> > smallest sleep available normally is time.sleep(.01) -- which brings my
> > samples/sec to a nice 100; but I need it a little faster.
>
>Where did you find that out?

Imperical testing -- I put in values smaller than .01, yet never got more 
than 100 samples per second. ;-) I then googled around and I saw a few 
other people found the same thing; but with no resolutions.

I *can* post some ugly code if necessary...

>I just did some experimenting ... I am running ActiveState Python 2.4.1 under
>Windows XP / cygwin.

I'm running under Linux From Scratch, book 4.0, kernel 2.4.29.

[code snippage]

>The first test is fairly consistent with time.sleep(0.001) doing what you
>expect.  The second is a bit puzzling to me, though...

Yea, seems to be a bit of weirdness there... Hrm....

Anyway, maybe I'll go snag 2.4.x and see what that does for me...

Laterz,
Roger "Merch" Merchberger

--
Roger "Merch" Merchberger   | Anarchy doesn't scale well. -- Me
zmerch at 30below.com.         |
SysAdmin, Iceberg Computers



More information about the Tutor mailing list