On 14/03/2012 01:18, Nadeem Vawda wrote:
So wallclock() falls back to a not-necessarily-monotonic time source if necessary, while monotonic() raises an exception in that case? ISTM that these don't need to be separate functions - rather, we can have one function that takes a flag (called require_monotonic, or something like that) telling it which failure mode to use. Does that make sense?
I don't think that time.monotonic() can fail in practice and it is available for all modern platforms (Windows, Mac OS X and OS implemented clock_gettime()).
On Windows, time.monotonic() fails with an OSError if QueryPerformanceFrequency() failed. QueryPerformanceFrequency() can fail if "the installed hardware does not support a high-resolution performance counter" according to Microsoft documentation. Windows uses the CPU RDTSC instruction, or the ACPI power management timer or event the old 8245 PIT. I think that you have at least one of this device on your computer.
I suppose that you can use a manual fallback to time.time() if time.monotonic() failed. If time.monotonic() fails, it fails directly at the first call. Example of a fallback working with Python < 3.3:
try: time.monotonic() except (OSError, AttributeError): get_time = time.time else: get_time = time.monotonic Victor _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com