[Python-checkins] peps: PEP 418: Define time.monotonic and time.steady

victor.stinner python-checkins at python.org
Tue Mar 27 01:30:59 CEST 2012


http://hg.python.org/peps/rev/37be6f757fe5
changeset:   4149:37be6f757fe5
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Mar 27 01:30:38 2012 +0200
summary:
  PEP 418: Define time.monotonic and time.steady

files:
  pep-0418.txt |  33 +++++++++++++++++++++++++++++++--
  1 files changed, 31 insertions(+), 2 deletions(-)


diff --git a/pep-0418.txt b/pep-0418.txt
--- a/pep-0418.txt
+++ b/pep-0418.txt
@@ -51,6 +51,32 @@
  * etc.
 
 
+Functions
+=========
+
+time.monotonic
+--------------
+
+Monotonic clock advancing at a steady rate relative to real time. It cannot go
+backward. It may be adjusted. The reference point of the returned value is
+undefined so only the difference of consecutive calls is valid.
+
+May raise an OSError on error.
+
+
+time.steady
+-----------
+
+This clock advances at a steady rate relative to real time. It may be adjusted.
+The reference point of the returned value is undefined so only the difference
+of consecutive calls is valid.
+
+If available, a monotonic clock is used. The function falls back to another
+clock if the monotonic clock failed or is not available.
+
+This function cannot fail.
+
+
 Clocks
 ======
 
@@ -234,6 +260,9 @@
 "A keyword argument that gets passed as a constant in the caller is usually
 poor API."
 
+Raising NotImplementedError for a function is something uncommon in Python and
+should be avoided.
+
 One function, no flag
 ---------------------
 
@@ -243,8 +272,8 @@
 attribute value would be None before the first call to time.steady().
 
 
-Workaround operating system bugs?
-=================================
+Working around operating system bugs?
+=====================================
 
 Should Python ensure manually that a monotonic clock is truly monotonic by
 computing the maximum with the clock value and the previous value?

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


More information about the Python-checkins mailing list