Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; ';-)': 0.03; 'intriguing': 0.09; 'received:151': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:skip:t 10': 0.09; 'wrong,': 0.09; 'def': 0.12; 'assume': 0.14; '(now': 0.16; 'be:': 0.16; 'emanuele': 0.16; 'intervening': 0.16; 'mean,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'seconds.': 0.16; 'skip:j 30': 0.16; 'do,': 0.16; 'header:User- Agent:1': 0.23; 'pass': 0.26; 'gets': 0.27; 'header:X-Complaints- To:1': 0.27; 'function': 0.29; '(maybe': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'writes:': 0.31; 'another': 0.32; 'maybe': 0.34; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'really': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'che': 0.60; 'most': 0.60; 'full': 0.61; 'simply': 0.61; "you're": 0.61; 'act': 0.63; 'kind': 0.63; 'become': 0.64; 'account': 0.65; 'due': 0.66; 'conservative': 0.84; 'quando': 0.84; 'slowed': 0.84; 'subject:over': 0.84; 'suspended,': 0.84; 'notion': 0.91; 'suspended': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lele Gaifax Subject: Re: time.monotonic() roll over Date: Fri, 05 Dec 2014 08:56:05 +0100 Organization: Nautilus Entertainments References: <54807cfd$0$2311$426a74cc@news.free.fr> <87vblr8lcw.fsf@elektro.pacujo.net> <87r3wf8jy8.fsf@elektro.pacujo.net> <87ppbzp9qq.fsf@elektro.pacujo.net> <5480fea7$0$12992$c3e8da3$5496439d@news.astraweb.com> <54811e7b$0$13004$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 151.62.83.183 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.51 (gnu/linux) Cancel-Lock: sha1:uv9BxpFv28TwzlU66xdd4Pt62FY= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417766184 news.xs4all.nl 2931 [2001:888:2000:d::a6]:48533 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81988 Steven D'Aprano writes: > The most conservative approach is to assume that while you're suspended, > *everything else* is suspended too, so when you resume you still have to > sleep for the full N seconds. That's an intriguing interpretation of what sleep() should do, but I fail to see *how* the function could even attempt to do that: should it keep its own notion of the elapsed time? I mean, one simplicistic, naive (and wrong) implementation of Dave's (and mine, FWIW) could be: def sleep(secs): now = time() while time() < (now + secs): pass # this is wrong, should really be some kind of "yield_cpu()" How would it become if it should take into account the intervening "coma"? Maybe something like def sleep(secs): nmillisleeps = secs * 1000 for i in range(nmillisleeps): now = time() while time() < (now + 0.001): pass ? Also, should it also assume that if the system suffers of a slowdown instead (maybe simply due to another process using the same /inefficient and wrong/ implementation of sleep() ;-) then everything else gets slowed down too, and act accordingly? just-for-the-sake-of-arguing-ly, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.