diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-10-12 15:51:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-12 15:51:56 (GMT) |
commit | cba9a0c6def70549046f1afa6a80e38fe706520e (patch) | |
tree | 1700dda3a2a2170cc5d0766387fe6f020540c44c /Modules/timemodule.c | |
parent | 0e61e67a57deb4abc677808201d7cf3c38138e02 (diff) | |
download | cpython-cba9a0c6def70549046f1afa6a80e38fe706520e.zip cpython-cba9a0c6def70549046f1afa6a80e38fe706520e.tar.gz cpython-cba9a0c6def70549046f1afa6a80e38fe706520e.tar.bz2 |
bpo-31773: time.perf_counter() uses again double (GH-3964)
time.clock() and time.perf_counter() now use again C double
internally.
Remove also _PyTime_GetWinPerfCounterWithInfo(): use
_PyTime_GetPerfCounterDoubleWithInfo() instead on Windows.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 2c0a8d6..3cb1b4e 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -88,19 +88,23 @@ floatclock(_Py_clock_info_t *info) } #endif /* HAVE_CLOCK */ +static PyObject* +perf_counter(_Py_clock_info_t *info) +{ + double t; + if (_PyTime_GetPerfCounterDoubleWithInfo(&t, info) < 0) { + return NULL; + } + return PyFloat_FromDouble(t); +} + #if defined(MS_WINDOWS) || defined(HAVE_CLOCK) #define PYCLOCK static PyObject* pyclock(_Py_clock_info_t *info) { #ifdef MS_WINDOWS - /* Win32 has better clock replacement; we have our own version, due to Mark - Hammond and Tim Peters */ - _PyTime_t t; - if (_PyTime_GetWinPerfCounterWithInfo(&t, info) < 0) { - return NULL; - } - return _PyFloat_FromPyTime(t); + return perf_counter(info); #else return floatclock(info); #endif @@ -936,16 +940,6 @@ PyDoc_STRVAR(monotonic_doc, \n\ Monotonic clock, cannot go backward."); -static PyObject* -perf_counter(_Py_clock_info_t *info) -{ - _PyTime_t t; - if (_PyTime_GetPerfCounterWithInfo(&t, info) < 0) { - return NULL; - } - return _PyFloat_FromPyTime(t); -} - static PyObject * time_perf_counter(PyObject *self, PyObject *unused) { |