PEP 418: Add time.get_clock_info()

This commit is contained in:
Victor Stinner 2012-04-01 04:11:08 +02:00
parent 196140e221
commit e30d4d8b81
1 changed files with 21 additions and 2 deletions

View File

@ -13,8 +13,8 @@ Python-Version: 3.3
Abstract Abstract
======== ========
Add time.monotonic(fallback=True) and time.highres() functions to Add time.monotonic(fallback=True), time.highres(), time.get_clock_info(name)
Python 3.3. functions to Python 3.3.
Rationale Rationale
@ -40,6 +40,7 @@ To fulfill the use cases, the functions' properties are:
clock is available, falls back to system clock by default, or raises clock is available, falls back to system clock by default, or raises
an OSError if *fallback* is False. time.monotonic(fallback=True) an OSError if *fallback* is False. time.monotonic(fallback=True)
cannot go backward. cannot go backward.
* time.get_clock_info(name): get information on the specified time function
time.time() time.time()
@ -208,6 +209,24 @@ Pseudo-code::
highres.use_performance_counter = (os.name == 'nt') highres.use_performance_counter = (os.name == 'nt')
highres.use_monotonic = hasattr(time, 'monotonic') highres.use_monotonic = hasattr(time, 'monotonic')
time.get_clock_info(name)
-------------------------
Get information on the specified time function as a dictionary. Only the following
names are accepted:
* "clock": time.clock()
* "highres": time.highres()
* "monotonic": time.monotonic()
* "time": time.time()
The following keys are always present:
* "function" (str): name of the underlying operating system function (ex:
"QueryPerformanceCounter()" or "clock_gettime(CLOCK_REALTIME)")
* "resolution" (float): resolution in seconds of the function
* "monotonic" (bool): True if the clock is monotonic
Hardware clocks Hardware clocks
=============== ===============