[Python-Dev] Rename time.steady(strict=True) to time.monotonic()?
Brian Curtin
brian at python.org
Sat Mar 24 00:28:28 CET 2012
On Mar 23, 2012 6:25 PM, "Victor Stinner" <victor.stinner at 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 time.steady(strict=True) by time.monotonic().
> That would avoid the need of an ugly NotImplementedError: if the OS
> has no monotonic clock, time.monotonic() will just not exist.
>
> 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 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 system administrator, may go backward.
>
> time.steady() is something like:
>
> try:
> return time.monotonic()
> except (NotImplementError, OSError):
> return time.time()
>
> time.time(), time.clock(), time.steady() are always available, whereas
> time.monotonic() will not be available on some platforms.
>
> Victor
This seems like it should have been a PEP, or maybe should become a PEP.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120323/69b80f61/attachment.html>
More information about the Python-Dev
mailing list