Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-25 Thread Janzert
On 3/24/2012 6:37 AM, Victor Stinner wrote: - time.monotonic(): monotonic clock, its speed may or may not be adjusted by NTP but it only goes forward, may raise an OSError - time.steady(): monotonic clock or the realtime clock, depending on what is available on the platform (use monotonic in

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-24 Thread Lennart Regebro
On Sat, Mar 24, 2012 at 00:36, Victor Stinner victor.stin...@gmail.com wrote: This seems like it should have been a PEP, or maybe should become a PEP. I replaced time.wallclock() by time.steady(strict=False) and time.monotonic() by time.steady(strict=True). This change solved the naming issue

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-24 Thread Antoine Pitrou
On Fri, 23 Mar 2012 22:38:19 -0500 Brian Curtin br...@python.org wrote: On Fri, Mar 23, 2012 at 18:38, Yury Selivanov yselivanov...@gmail.com wrote: On 2012-03-23, at 7:28 PM, Brian Curtin wrote: This seems like it should have been a PEP, or maybe should become a PEP. Why?  AFAIK Victor

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-24 Thread Victor Stinner
Does this mean that there are circumstances where monotonic will work for a while, but then fail? No. time.monotonic() always work or always fail. If monotonic() failed, steady() doesn't call it again. Otherwise, we would only need to check monotonic once, when the time module is first

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-24 Thread Victor Stinner
- time.monotonic(): monotonic clock, its speed may or may not be adjusted by NTP but it only goes forward, may raise an OSError - time.steady(): monotonic clock or the realtime clock, depending on what is available on the platform (use monotonic in priority). may be adjusted by NTP or the

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-24 Thread Victor Stinner
Oh, I was not aware of this issue. Do you suggest to not use QueryPerformanceCounter() on Windows to implement a monotonic clock? I do not have an opinion on the best way to implement monotonic to guarantee that it actually is monotonic. I opened an issue: http://bugs.python.org/issue14397

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-24 Thread Stephen J. Turnbull
On Sat, Mar 24, 2012 at 4:38 AM, Brian Curtin br...@python.org wrote: On Fri, Mar 23, 2012 at 18:38, Yury Selivanov yselivanov...@gmail.com wrote: On 2012-03-23, at 7:28 PM, Brian Curtin wrote: This seems like it should have been a PEP, or maybe should become a PEP. Why?  AFAIK Victor just

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-24 Thread Martin v. Löwis
I don't see what is the use case requiring a is truly monotonic clock. A clock that is purely monotonic may not be useful. However, people typically imply that it will have a certain minimum progress (seconds advanced/real seconds passed). Then you can use it for timeouts. Regards, Martin

[Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Victor Stinner
Hi, time.steady(strict=True) looks to be confusing for most people, some of them don't understand the purpose of the flag and others don't like a flag changing the behaviour of the function. I propose to replace time.steady(strict=True) by time.monotonic(). That would avoid the need of an ugly

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Brian Curtin
On Mar 23, 2012 6:25 PM, Victor Stinner victor.stin...@gmail.com wrote: Hi, time.steady(strict=True) looks to be confusing for most people, some of them don't understand the purpose of the flag and others don't like a flag changing the behaviour of the function. I propose to replace

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Victor Stinner
This seems like it should have been a PEP, or maybe should become a PEP. I replaced time.wallclock() by time.steady(strict=False) and time.monotonic() by time.steady(strict=True). This change solved the naming issue of time.wallclock(), but it was a bad idea to merge monotonic() feature into

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Yury Selivanov
On 2012-03-23, at 7:25 PM, Victor Stinner wrote: - time.steady(): monotonic clock or the realtime clock, depending on what is available on the platform (use monotonic in priority). may be adjusted by NTP or the system administrator, may go backward. time.steady() is something like: try:

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Victor Stinner
time.steady() is something like: try:  return time.monotonic() except (NotImplementError, OSError):  return time.time() Is the use of weak monotonic time so wide-spread in the stdlib that we need the 'steady()' function?  If it's just two modules then it's not worth adding it. The

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Steven D'Aprano
Victor Stinner wrote: [...] So we will have: - time.time(): realtime, can be adjusted by the system administrator (manually) or automatically by NTP - time.clock(): monotonic clock on Windows, CPU time on UNIX - time.monotonic(): monotonic clock, its speed may or may not be adjusted by NTP but

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Steven D'Aprano
Victor Stinner wrote: - time.clock(): monotonic clock on Windows, CPU time on UNIX Actually, I think that is not correct. Or at least *was* not correct in 2006. http://bytes.com/topic/python/answers/527849-time-clock-going-backwards -- Steven

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Victor Stinner
Question: under what circumstances will monotonic() exist but raise OSError? On Windows, OSError is raised if QueryPerformanceFrequency fails. Extract of Microsoft doc: If the function fails, the return value is zero. To get extended error information, call GetLastError. For example, if the

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Victor Stinner
- time.clock(): monotonic clock on Windows, CPU time on UNIX Actually, I think that is not correct. Or at least *was* not correct in 2006. http://bytes.com/topic/python/answers/527849-time-clock-going-backwards Oh, I was not aware of this issue. Do you suggest to not use

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Steven D'Aprano
Victor Stinner wrote: Is steady() merely a convenience function to avoid the user having to write something like this? steady() remembers if the last call to monotonic failed or not. The real implementation is closer to something like: def steady(): if not steady.has_monotonic: return

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Janzert
On 3/23/2012 7:25 PM, Victor Stinner wrote: [snip] - time.monotonic(): monotonic clock, its speed may or may not be adjusted by NTP but it only goes forward, may raise an OSError - time.steady(): monotonic clock or the realtime clock, depending on what is available on the platform (use monotonic

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Steven D'Aprano
Victor Stinner wrote: - time.clock(): monotonic clock on Windows, CPU time on UNIX Actually, I think that is not correct. Or at least *was* not correct in 2006. http://bytes.com/topic/python/answers/527849-time-clock-going-backwards Oh, I was not aware of this issue. Do you suggest to not

[Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Jim J. Jewett
In http://mail.python.org/pipermail/python-dev/2012-March/118024.html Steven D'Aprano wrote: What makes this steady, given that it can be adjusted and it can go backwards? It is best-effort for steady, but putting best in the name would be an attractive nuisance. Is steady() merely a

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Brian Curtin
On Fri, Mar 23, 2012 at 18:38, Yury Selivanov yselivanov...@gmail.com wrote: On 2012-03-23, at 7:28 PM, Brian Curtin wrote: This seems like it should have been a PEP, or maybe should become a PEP. Why?  AFAIK Victor just proposes to add two new functions: monotonic() and steady(). We just

Re: [Python-Dev] Rename time.steady(strict=True) to time.monotonic()?

2012-03-23 Thread Jeffrey Yasskin
On Fri, Mar 23, 2012 at 4:25 PM, Victor Stinner victor.stin...@gmail.com wrote: Hi, time.steady(strict=True) looks to be confusing for most people, some of them don't understand the purpose of the flag and others don't like a flag changing the behaviour of the function. I propose to replace