[Python-checkins] peps: PEP 418: Add 3 alternatives

victor.stinner python-checkins at python.org
Wed Apr 4 01:00:53 CEST 2012


http://hg.python.org/peps/rev/763be41b879b
changeset:   4194:763be41b879b
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Apr 04 01:00:46 2012 +0200
summary:
  PEP 418: Add 3 alternatives

files:
  pep-0418.txt |  41 ++++++++++++++++++++++++++++++++++++++++
  1 files changed, 41 insertions(+), 0 deletions(-)


diff --git a/pep-0418.txt b/pep-0418.txt
--- a/pep-0418.txt
+++ b/pep-0418.txt
@@ -792,6 +792,47 @@
   a monotonic clock with an unspecified starting point
 
 
+Only expose operating system clocks
+-----------------------------------
+
+To not have to define high-level clocks, which is a difficult task, a simpler
+approach is to only expose operating system clocks. time.clock_gettime() and
+related clock identifiers were already added to Python 3.3 for example.
+
+
+Don't fallback on system clock
+------------------------------
+
+time.monotonic() is always a monotonic clock and is only available if the
+operating system provides a monotonic clock.
+
+time.highres() is only available if the operating system provides a clock with
+a high resolution (e.g. at least a microsecond or better).
+
+
+One function choosing the clock from a list of constrains
+---------------------------------------------------------
+
+time.get_clock(*flags) with the following flags:
+
+ * time.MONOTONIC: clock cannot go backard
+ * time.STEADY: clock rate is steady and the clock is not adjusted
+ * time.HIGHRES: clock with the highest resolutions
+
+time.get_clock() returns None if the clock is found and so calls can be chained
+using the or operator. Example::
+
+ func = time.get_clock(time.MONOTONIC) or time.get_clock(time.STEADY) or time.time()
+
+Example of flags of system clocks:
+
+ * QueryPerformanceCounter: MONOTONIC | HIGHRES
+ * GetTickCount: MONOTONIC | STEADY
+ * CLOCK_MONOTONIC: MONOTONIC | STEADY (or only MONOTONIC on Linux)
+ * CLOCK_MONOTONIC_RAW: MONOTONIC | STEADY
+ * gettimeofday(): (none)
+
+
 One function with a flag: time.monotonic(fallback=True)
 -------------------------------------------------------
 

-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list