[Python-Dev] Drop the new time.wallclock() function? (original) (raw)
Victor Stinner victor.stinner at gmail.com
Wed Mar 14 13:27:19 CET 2012
- Previous message: [Python-Dev] Drop the new time.wallclock() function?
- Next message: [Python-Dev] Drop the new time.wallclock() function?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2012/3/14 Antoine Pitrou <solipsis at pitrou.net>:
On Wed, 14 Mar 2012 02:03:42 +0100 Victor Stinner <victor.stinner at gmail.com> wrote:
We may merge both functions with a flag to be able to disable the fallback. Example: - time.realtime(): best-effort monotonic, with a fallback - time.realtime(monotonic=True): monotonic, may raise OSError or NotImplementedError That's a rather awful name. time.time() is the real time. time.monotonic(fallback=False) would be a better API.
I would prefer to enable the fallback by default with a warning in the doc, just because it is more convinient and it is what user want even if they don't know that they need a fallback :-)
Enabling the fallback by default allow to write such simple code:
try: from time import monotonic as get_time except ImportError:
Python < 3.3
from time import time as get_time
Use time.monotonic(strict=True) if you need a truly monotonic clock.
monotonic() may not be the best name in this case. Jeffrey Yasskin proposed time.steady_clock(), so time.steady_clock(monotonic=False)?
Victor
- Previous message: [Python-Dev] Drop the new time.wallclock() function?
- Next message: [Python-Dev] Drop the new time.wallclock() function?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]