[Python-checkins] peps: PEP 418: Fix clock_precision.py, time.monotonic() is not always present
victor.stinner
python-checkins at python.org
Wed Apr 18 00:39:08 CEST 2012
http://hg.python.org/peps/rev/9496665d7e5f
changeset: 4260:9496665d7e5f
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Apr 18 00:39:03 2012 +0200
summary:
PEP 418: Fix clock_precision.py, time.monotonic() is not always present
files:
pep-0418/clock_precision.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/pep-0418/clock_precision.py b/pep-0418/clock_precision.py
--- a/pep-0418/clock_precision.py
+++ b/pep-0418/clock_precision.py
@@ -36,7 +36,11 @@
print("- precision in Python: %s" % format_duration(precision))
-for name in ('clock', 'perf_counter', 'process_time', 'monotonic', 'time'):
+clocks = ('clock', 'perf_counter', 'process_time')
+if hasattr(time, 'monotonic'):
+ clocks.append('monotonic')
+clocks.append('time')
+for name in clocks:
func = getattr(time, name)
test_clock("%s()" % name, func)
info = time.get_clock_info(name)
--
Repository URL: http://hg.python.org/peps
More information about the Python-checkins
mailing list