[Python-Dev] Rename time.steady(strict=True) to time.monotonic()?
Steven D'Aprano
steve at pearwood.info
Sat Mar 24 01:02:36 CET 2012
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 it only goes forward, may raise an OSError
This all sounds good to me. +1 up to this point.
Question: under what circumstances will monotonic() exist but raise 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.
What makes this "steady", given that it can be adjusted and it can go
backwards? Doesn't sound steady to me.
Is steady() merely a convenience function to avoid the user having to write
something like this?
try:
mytimer = time.monotonic
except AttributeError:
mytimer = time.time
or inline:
> try:
> return time.monotonic()
> except (NotImplementError, OSError):
> return time.time()
Should that be (AttributeError, OSError) instead?
--
Steven
More information about the Python-Dev
mailing list