[Python-Dev] cpython: Issue #10278: Add an optional strict argument to time.steady(), False by default

Michael Foord fuzzyman at voidspace.org.uk
Sat Mar 17 21:47:47 CET 2012


On 17 Mar 2012, at 08:49, Georg Brandl wrote:

> On 03/15/2012 01:17 AM, victor.stinner wrote:
>> http://hg.python.org/cpython/rev/27441e0d6a75
>> changeset:   75672:27441e0d6a75
>> user:        Victor Stinner <victor.stinner at gmail.com>
>> date:        Thu Mar 15 01:17:09 2012 +0100
>> summary:
>>  Issue #10278: Add an optional strict argument to time.steady(), False by default
>> 
>> files:
>>  Doc/library/time.rst  |   7 +++-
>>  Lib/test/test_time.py |  10 +++++
>>  Modules/timemodule.c  |  58 +++++++++++++++++++++---------
>>  3 files changed, 57 insertions(+), 18 deletions(-)
>> 
>> 
>> diff --git a/Doc/library/time.rst b/Doc/library/time.rst
>> --- a/Doc/library/time.rst
>> +++ b/Doc/library/time.rst
>> @@ -226,7 +226,7 @@
>>    The earliest date for which it can generate a time is platform-dependent.
>> 
>> 
>> -.. function:: steady()
>> +.. function:: steady(strict=False)
>> 
>>    .. index::
>>       single: benchmarking
>> @@ -236,6 +236,11 @@
>>    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. By default, if *strict* is False,
>> +   the function falls back to another clock if the monotonic clock failed or is
>> +   not available. If *strict* is True, raise an :exc:`OSError` on error or
>> +   :exc:`NotImplementedError` if no monotonic clock is available.
> 
> This is not clear to me.  Why wouldn't it raise OSError on error even with
> strict=False?  Please clarify which exception is raised in which case.

It seems clear to me. It doesn't raise exceptions when strict=False because it falls back to a non-monotonic clock. If strict is True and a non-monotonic clock is not available it raises OSError or NotImplementedError.

Michael

> 
> Georg
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
> 


--
http://www.voidspace.org.uk/


May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing 
http://www.sqlite.org/different.html







More information about the Python-Dev mailing list