Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

Re: this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed)

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


steve at pearwood

Apr 6, 2012, 3:12 AM

Post #1 of 5 (207 views)
Permalink
Re: this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed)

Glyph Lefkowitz wrote:
> On Apr 5, 2012, at 8:07 PM, Zooko Wilcox-O'Hearn wrote:

>> 2. Those who think that "monotonic clock" means a clock that never jumps,
>> and that runs at a rate approximating the rate of real time. This is a
>> very useful kind of clock to have! It is what C++ now calls a "steady
>> clock". It is what all the major operating systems provide.
>
> All clocks run at a rate approximating the rate of real time. That is very
> close to the definition of the word "clock" in this context. All clocks
> have flaws in that approximation, and really those flaws are the whole
> point of access to distinct clock APIs. Different applications can cope
> with different flaws.

I think that this is incorrect.

py> time.clock(); time.sleep(10); time.clock()
0.41
0.41




--
Steven

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


p.f.moore at gmail

Apr 6, 2012, 4:55 AM

Post #2 of 5 (193 views)
Permalink
Re: this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed) [In reply to]

On 6 April 2012 11:12, Steven D'Aprano <steve [at] pearwood> wrote:

> Glyph Lefkowitz wrote:
>
>> On Apr 5, 2012, at 8:07 PM, Zooko Wilcox-O'Hearn wrote:
>>
>
> 2. Those who think that "monotonic clock" means a clock that never jumps,
>>> and that runs at a rate approximating the rate of real time. This is a
>>> very useful kind of clock to have! It is what C++ now calls a "steady
>>> clock". It is what all the major operating systems provide.
>>>
>>
>> All clocks run at a rate approximating the rate of real time. That is
>> very
>> close to the definition of the word "clock" in this context. All clocks
>> have flaws in that approximation, and really those flaws are the whole
>> point of access to distinct clock APIs. Different applications can cope
>> with different flaws.
>>
>
> I think that this is incorrect.
>
> py> time.clock(); time.sleep(10); time.clock()
> 0.41
> 0.41
>

Blame Python's use of CPU time in clock() on Unix for that. On Windows:

>>> time.clock(); time.sleep(10); time.clock()
14.879754156329385
24.879591008462793

That''s a backward compatibility issue, though - I'd be arguing that
time.clock() is the best name for "normally the right clock for interval,
benchmark or timeout uses as long as you don't care about oddities like
suspend" otherwise. Given that this name is taken, I'd argue for
time.wallclock. I'm not familiar enough with the terminology to know what
to expect from terms like monotonic, steady, raw and the like.

Paul.


kristjan at ccpgames

Apr 6, 2012, 10:07 AM

Post #3 of 5 (191 views)
Permalink
Re: this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed) [In reply to]

This is the original reason for the original defect (issue 10278)
unix' clock() doesn't actually provide a clock in this sense, it provides a resource usage metric.
K

________________________________________
Frá: python-dev-bounces+kristjan=ccpgames.com [at] python [python-dev-bounces+kristjan=ccpgames.com [at] python] fyrir h&#246;nd Steven D'Aprano [steve [at] pearwood]
Sent: 6. apríl 2012 10:12
To: Python-Dev
Efni: Re: [Python-Dev] this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed)

I think that this is incorrect.

py> time.clock(); time.sleep(10); time.clock()
0.41
0.41




--
Steven

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/kristjan%40ccpgames.com
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


cs at zip

Apr 6, 2012, 3:28 PM

Post #4 of 5 (190 views)
Permalink
Re: this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed) [In reply to]

On 06Apr2012 17:07, Kristj�n Valur J�nsson <kristjan [at] ccpgames> wrote:
| Steven D'Aprano:
| > I think that this is incorrect.
| > py> time.clock(); time.sleep(10); time.clock()
| > 0.41
| > 0.41
|
| This is the original reason for the original defect (issue 10278)
| unix' clock() doesn't actually provide a clock in this sense, it provides a resource usage metric.

Yeah:-( Its help says "Return the CPU time or real time since [...]".
Two very different things, as demonstrated. I suppose neither goes
backwards, but this seems like a classic example of the "useless
monotonic clock" against which Greg Ewing railed.

And why? For one thing, because one can't inspect its metadata to find
out what it does.
--
Cameron Simpson <cs [at] zip> DoD#743
http://www.cskk.ezoshosting.com/cs/

Tens of thousands of messages, hundreds of points of view. It was not called
the Net of a Million Lies for nothing. - Vernor Vinge, _A Fire Upon The Deep_
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


victor.stinner at gmail

Apr 6, 2012, 4:16 PM

Post #5 of 5 (192 views)
Permalink
Re: this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed) [In reply to]

> | This is the original reason for the original defect (issue 10278)
> | unix' clock() doesn't actually provide a clock in this sense, it provides a resource usage metric.
>
> Yeah:-( Its help says "Return the CPU time or real time since [...]".
> Two very different things, as demonstrated. I suppose neither goes
> backwards, but this seems like a classic example of the "useless
> monotonic clock" against which Greg Ewing railed.
>
> And why? For one thing, because one can't inspect its metadata to find
> out what it does.

Should I add another key to the result of
time.get_clock_info('clock')? How can we define "clock on Windows"
(almost monotonic and steady clock) vs "clock on UNIX" (CPU time) with
a flag or a value?

Victor
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.