diff --git a/Modules/timemodule.c b/Modules/timemodule.c --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -49,18 +49,45 @@ static OSVERSIONINFOEX winver; #endif +/*[clinic input] +module time +[clinic start generated code]*/ +/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/ + + +/*[clinic input] +time.time + +Return the current time in seconds since the Epoch. + +Fractions of a second may be present if the system clock provides them. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_time__doc__, +"time(module)\n" +"Return the current time in seconds since the Epoch.\n" +"\n" +"Fractions of a second may be present if the system clock provides them."); + +#define TIME_TIME_METHODDEF \ + {"time", (PyCFunction)time_time, METH_NOARGS, time_time__doc__}, + static PyObject * -time_time(PyObject *self, PyObject *unused) +time_time_impl(PyModuleDef *module); + +static PyObject * +time_time(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return time_time_impl(module); +} + +static PyObject * +time_time_impl(PyModuleDef *module) +/*[clinic end generated code: checksum=bc667fb16b5307f6ec15203f6af828f0081f1657]*/ { return floattime(NULL); } -PyDoc_STRVAR(time_doc, -"time() -> floating point number\n\ -\n\ -Return the current time in seconds since the Epoch.\n\ -Fractions of a second may be present if the system clock provides them."); - #if defined(HAVE_CLOCK) #ifndef CLOCKS_PER_SEC @@ -142,31 +169,86 @@ return floatclock(info); } +/*[clinic input] +time.clock + +Return the time since the start of the process or last call + +Return the CPU time or real time since the start of the process or since the +first call to clock(). This has as much precision as the system records. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_clock__doc__, +"clock(module)\n" +"Return the time since the start of the process or last call\n" +"\n" +"Return the CPU time or real time since the start of the process or since the\n" +"first call to clock(). This has as much precision as the system records."); + +#define TIME_CLOCK_METHODDEF \ + {"clock", (PyCFunction)time_clock, METH_NOARGS, time_clock__doc__}, + static PyObject * -time_clock(PyObject *self, PyObject *unused) +time_clock_impl(PyModuleDef *module); + +static PyObject * +time_clock(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return time_clock_impl(module); +} + +static PyObject * +time_clock_impl(PyModuleDef *module) +/*[clinic end generated code: checksum=74e682b14d2b098358c7b6bd50db30e669c8d339]*/ + { return pyclock(NULL); } - -PyDoc_STRVAR(clock_doc, -"clock() -> floating point number\n\ -\n\ -Return the CPU time or real time since the start of the process or since\n\ -the first call to clock(). This has as much precision as the system\n\ -records."); -#endif +#endif /* WIN32_PERF_COUNTER || HAVE_CLOCK */ #ifdef HAVE_CLOCK_GETTIME +/*[clinic input] +time.clock_gettime + + clk_id: int + / + +Return the time of the specified clock clk_id +[clinic start generated code]*/ + +PyDoc_STRVAR(time_clock_gettime__doc__, +"clock_gettime(module, clk_id)\n" +"Return the time of the specified clock clk_id"); + +#define TIME_CLOCK_GETTIME_METHODDEF \ + {"clock_gettime", (PyCFunction)time_clock_gettime, METH_VARARGS, time_clock_gettime__doc__}, + static PyObject * -time_clock_gettime(PyObject *self, PyObject *args) +time_clock_gettime_impl(PyModuleDef *module, int clk_id); + +static PyObject * +time_clock_gettime(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int clk_id; + + if (!PyArg_ParseTuple(args, + "i:clock_gettime", + &clk_id)) + goto exit; + return_value = time_clock_gettime_impl(module, clk_id); + +exit: + return return_value; +} + +static PyObject * +time_clock_gettime_impl(PyModuleDef *module, int clk_id) +/*[clinic end generated code: checksum=c38a6ebdeba719d030eff553952abae6962dc01e]*/ { int ret; - int clk_id; struct timespec tp; - if (!PyArg_ParseTuple(args, "i:clock_gettime", &clk_id)) - return NULL; - ret = clock_gettime((clockid_t)clk_id, &tp); if (ret != 0) { PyErr_SetFromErrno(PyExc_IOError); @@ -175,24 +257,53 @@ return PyFloat_FromDouble(tp.tv_sec + tp.tv_nsec * 1e-9); } -PyDoc_STRVAR(clock_gettime_doc, -"clock_gettime(clk_id) -> floating point number\n\ -\n\ -Return the time of the specified clock clk_id."); + +/*[clinic input] +time.clock_settime + + clk_id: int + obj: object + / + +Set the time of the specified clock clk_id. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_clock_settime__doc__, +"clock_settime(module, clk_id, obj)\n" +"Set the time of the specified clock clk_id."); + +#define TIME_CLOCK_SETTIME_METHODDEF \ + {"clock_settime", (PyCFunction)time_clock_settime, METH_VARARGS, time_clock_settime__doc__}, static PyObject * -time_clock_settime(PyObject *self, PyObject *args) +time_clock_settime_impl(PyModuleDef *module, int clk_id, PyObject *obj); + +static PyObject * +time_clock_settime(PyModuleDef *module, PyObject *args) { + PyObject *return_value = NULL; int clk_id; PyObject *obj; + + if (!PyArg_ParseTuple(args, + "iO:clock_settime", + &clk_id, &obj)) + goto exit; + return_value = time_clock_settime_impl(module, clk_id, obj); + +exit: + return return_value; +} + +static PyObject * +time_clock_settime_impl(PyModuleDef *module, int clk_id, PyObject *obj) +/*[clinic end generated code: checksum=1ede5d04fc12767863464d44156ab007d9ecfe3b]*/ +{ time_t tv_sec; long tv_nsec; struct timespec tp; int ret; - if (!PyArg_ParseTuple(args, "iO:clock_settime", &clk_id, &obj)) - return NULL; - if (_PyTime_ObjectToTimespec(obj, &tv_sec, &tv_nsec) == -1) return NULL; tp.tv_sec = tv_sec; @@ -206,21 +317,49 @@ Py_RETURN_NONE; } -PyDoc_STRVAR(clock_settime_doc, -"clock_settime(clk_id, time)\n\ -\n\ -Set the time of the specified clock clk_id."); + +/*[clinic input] +time.clock_getres + + clk_id: int + / + +Return the resolution (precision) of the specified clock clk_id. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_clock_getres__doc__, +"clock_getres(module, clk_id)\n" +"Return the resolution (precision) of the specified clock clk_id."); + +#define TIME_CLOCK_GETRES_METHODDEF \ + {"clock_getres", (PyCFunction)time_clock_getres, METH_VARARGS, time_clock_getres__doc__}, static PyObject * -time_clock_getres(PyObject *self, PyObject *args) +time_clock_getres_impl(PyModuleDef *module, int clk_id); + +static PyObject * +time_clock_getres(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int clk_id; + + if (!PyArg_ParseTuple(args, + "i:clock_getres", + &clk_id)) + goto exit; + return_value = time_clock_getres_impl(module, clk_id); + +exit: + return return_value; +} + +static PyObject * +time_clock_getres_impl(PyModuleDef *module, int clk_id) +/*[clinic end generated code: checksum=8faa11987912221133947abedc69161ed0f48e8e]*/ { int ret; - int clk_id; struct timespec tp; - if (!PyArg_ParseTuple(args, "i:clock_getres", &clk_id)) - return NULL; - ret = clock_getres((clockid_t)clk_id, &tp); if (ret != 0) { PyErr_SetFromErrno(PyExc_IOError); @@ -229,19 +368,51 @@ return PyFloat_FromDouble(tp.tv_sec + tp.tv_nsec * 1e-9); } - -PyDoc_STRVAR(clock_getres_doc, -"clock_getres(clk_id) -> floating point number\n\ -\n\ -Return the resolution (precision) of the specified clock clk_id."); #endif /* HAVE_CLOCK_GETTIME */ +/*[clinic input] +time.sleep + + secs: double + / + +Delay execution for a given number of seconds. + +The argument may be a floating point number for subsecond precision. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_sleep__doc__, +"sleep(module, secs)\n" +"Delay execution for a given number of seconds.\n" +"\n" +"The argument may be a floating point number for subsecond precision."); + +#define TIME_SLEEP_METHODDEF \ + {"sleep", (PyCFunction)time_sleep, METH_VARARGS, time_sleep__doc__}, + static PyObject * -time_sleep(PyObject *self, PyObject *args) +time_sleep_impl(PyModuleDef *module, double secs); + +static PyObject * +time_sleep(PyModuleDef *module, PyObject *args) { + PyObject *return_value = NULL; double secs; - if (!PyArg_ParseTuple(args, "d:sleep", &secs)) - return NULL; + + if (!PyArg_ParseTuple(args, + "d:sleep", + &secs)) + goto exit; + return_value = time_sleep_impl(module, secs); + +exit: + return return_value; +} + +static PyObject * +time_sleep_impl(PyModuleDef *module, double secs) +/*[clinic end generated code: checksum=8933a92fad444586e9b863ca8a5266a544850279]*/ +{ if (secs < 0) { PyErr_SetString(PyExc_ValueError, "sleep length must be non-negative"); @@ -253,11 +424,6 @@ return Py_None; } -PyDoc_STRVAR(sleep_doc, -"sleep(seconds)\n\ -\n\ -Delay execution for a given number of seconds. The argument may be\n\ -a floating point number for subsecond precision."); static PyStructSequence_Field struct_time_type_fields[] = { {"tm_year", "year, for example, 1993"}, @@ -348,6 +514,8 @@ return 1; } +/* AC 3.5: No Python value available that gives same behavior + as when not specifying parameter */ static PyObject * time_gmtime(PyObject *self, PyObject *args) { @@ -400,6 +568,8 @@ return 0; } +/* AC 3.5: No Python value available that gives same behavior + as when not specifying parameter */ static PyObject * time_localtime(PyObject *self, PyObject *args) { @@ -565,6 +735,8 @@ #define time_strlen strlen #endif +/* AC 3.5: No Python value available that gives same behavior + as when not specifying parameter */ static PyObject * time_strftime(PyObject *self, PyObject *args) { @@ -726,30 +898,110 @@ \n" STRFTIME_FORMAT_CODES); #endif /* HAVE_STRFTIME */ +/*[clinic input] +time.strptime + + string: str + format: str + / + +Parse a string to a time tuple according to a format specification. + +For the full list of format codes, see the library reference manual +and the documentation for the C library strftime function on your +platform. + +Commonly used format codes are: + +%Y Year with century as a decimal number. +%m Month as a decimal number [01,12]. +%d Day of the month as a decimal number [01,31]. +%H Hour (24-hour clock) as a decimal number [00,23]. +%M Minute as a decimal number [00,59]. +%S Second as a decimal number [00,61]. +%z Time zone offset from UTC. +%a Locale's abbreviated weekday name. +%A Locale's full weekday name. +%b Locale's abbreviated month name. +%B Locale's full month name. +%c Locale's appropriate date and time representation. +%I Hour (12-hour clock) as a decimal number [01,12]. +%p Locale's equivalent of either AM or PM. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_strptime__doc__, +"strptime(module, string, format)\n" +"Parse a string to a time tuple according to a format specification.\n" +"\n" +"For the full list of format codes, see the library reference manual\n" +"and the documentation for the C library strftime function on your\n" +"platform.\n" +"\n" +"Commonly used format codes are:\n" +"\n" +"%Y Year with century as a decimal number.\n" +"%m Month as a decimal number [01,12].\n" +"%d Day of the month as a decimal number [01,31].\n" +"%H Hour (24-hour clock) as a decimal number [00,23].\n" +"%M Minute as a decimal number [00,59].\n" +"%S Second as a decimal number [00,61].\n" +"%z Time zone offset from UTC.\n" +"%a Locale\'s abbreviated weekday name.\n" +"%A Locale\'s full weekday name.\n" +"%b Locale\'s abbreviated month name.\n" +"%B Locale\'s full month name.\n" +"%c Locale\'s appropriate date and time representation.\n" +"%I Hour (12-hour clock) as a decimal number [01,12].\n" +"%p Locale\'s equivalent of either AM or PM."); + +#define TIME_STRPTIME_METHODDEF \ + {"strptime", (PyCFunction)time_strptime, METH_VARARGS, time_strptime__doc__}, + static PyObject * -time_strptime(PyObject *self, PyObject *args) +time_strptime_impl(PyModuleDef *module, const char *string, const char *format); + +static PyObject * +time_strptime(PyModuleDef *module, PyObject *args) { - PyObject *strptime_module = PyImport_ImportModuleNoBlock("_strptime"); + PyObject *return_value = NULL; + const char *string; + const char *format; + + if (!PyArg_ParseTuple(args, + "ss:strptime", + &string, &format)) + goto exit; + return_value = time_strptime_impl(module, string, format); + +exit: + return return_value; +} + +static PyObject * +time_strptime_impl(PyModuleDef *module, const char *string, const char *format) +/*[clinic end generated code: checksum=0cd895d8b59fa74977f682c933cb12030496a0c9]*/ +{ + PyObject *strptime_module = PyImport_ImportModule("_strptime"); PyObject *strptime_result; + PyObject* strptime_args; + _Py_IDENTIFIER(_strptime_time); if (!strptime_module) return NULL; + + strptime_args = Py_BuildValue("ss", string, format); + if (strptime_args == NULL) + return NULL; + strptime_result = _PyObject_CallMethodId(strptime_module, - &PyId__strptime_time, "O", args); + &PyId__strptime_time, "O", + strptime_args); Py_DECREF(strptime_module); return strptime_result; } -PyDoc_STRVAR(strptime_doc, -"strptime(string, format) -> struct_time\n\ -\n\ -Parse a string to a time tuple according to a format specification.\n\ -See the library reference manual for formatting codes (same as\n\ -strftime()).\n\ -\n" STRFTIME_FORMAT_CODES); - static PyObject * _asctime(struct tm *timeptr) { @@ -771,6 +1023,8 @@ 1900 + timeptr->tm_year); } +/* AC 3.5: No Python value available that gives same behavior + as when not specifying parameter */ static PyObject * time_asctime(PyObject *self, PyObject *args) { @@ -796,6 +1050,8 @@ When the time tuple is not present, current time as returned by localtime()\n\ is used."); +/* AC 3.5: No Python value available that gives same behavior + as when not specifying parameter */ static PyObject * time_ctime(PyObject *self, PyObject *args) { @@ -816,6 +1072,7 @@ not present, current time as returned by localtime() is used."); #ifdef HAVE_MKTIME +/* AC 3.4: Not sure how to do this without excessive code duplication */ static PyObject * time_mktime(PyObject *self, PyObject *tup) { @@ -856,8 +1113,54 @@ #ifdef HAVE_WORKING_TZSET static void PyInit_timezone(PyObject *module); +/*[clinic input] +time.tzset + +Initialize the local timezone + +Initialize (or reinitialize) the local timezone to the value stored in +os.environ['TZ']. The TZ environment variable should be specified in standard +Unix timezone format as documented in the tzset man page (eg. 'US/Eastern', +'Europe/Amsterdam'). Unknown timezones will silently fall back to UTC. If the +TZ environment variable is not set, the local timezone is set to the systems +best guess of wallclock time. + +Changing the TZ environment variable without calling tzset *may* change the +local timezone used by methods such as localtime, but this behaviour should +not be relied on. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_tzset__doc__, +"tzset(module)\n" +"Initialize the local timezone\n" +"\n" +"Initialize (or reinitialize) the local timezone to the value stored in\n" +"os.environ[\'TZ\']. The TZ environment variable should be specified in standard\n" +"Unix timezone format as documented in the tzset man page (eg. \'US/Eastern\',\n" +"\'Europe/Amsterdam\'). Unknown timezones will silently fall back to UTC. If the\n" +"TZ environment variable is not set, the local timezone is set to the systems\n" +"best guess of wallclock time.\n" +"\n" +"Changing the TZ environment variable without calling tzset *may* change the\n" +"local timezone used by methods such as localtime, but this behaviour should\n" +"not be relied on."); + +#define TIME_TZSET_METHODDEF \ + {"tzset", (PyCFunction)time_tzset, METH_NOARGS, time_tzset__doc__}, + static PyObject * -time_tzset(PyObject *self, PyObject *unused) +time_tzset_impl(PyModuleDef *module); + +static PyObject * +time_tzset(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return time_tzset_impl(module); +} + +static PyObject * +time_tzset_impl(PyModuleDef *module) +/*[clinic end generated code: checksum=3ac334cc84cd4e70849590f8a6bfa8f6d9255235]*/ + { PyObject* m; @@ -878,18 +1181,6 @@ return Py_None; } -PyDoc_STRVAR(tzset_doc, -"tzset()\n\ -\n\ -Initialize, or reinitialize, the local timezone to the value stored in\n\ -os.environ['TZ']. The TZ environment variable should be specified in\n\ -standard Unix timezone format as documented in the tzset man page\n\ -(eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently\n\ -fall back to UTC. If the TZ environment variable is not set, the local\n\ -timezone is set to the systems best guess of wallclock time.\n\ -Changing the TZ environment variable without calling tzset *may* change\n\ -the local timezone used by methods such as localtime, but this behaviour\n\ -should not be relied on."); #endif /* HAVE_WORKING_TZSET */ #if defined(MS_WINDOWS) || defined(__APPLE__) \ @@ -1010,17 +1301,41 @@ #endif } +/*[clinic input] +time.monotonic + +Retrieve timestamp from the system's monotonic clock + +The monotonic clock is guaranteed to never go backwards. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_monotonic__doc__, +"monotonic(module)\n" +"Retrieve timestamp from the system\'s monotonic clock\n" +"\n" +"The monotonic clock is guaranteed to never go backwards."); + +#define TIME_MONOTONIC_METHODDEF \ + {"monotonic", (PyCFunction)time_monotonic, METH_NOARGS, time_monotonic__doc__}, + static PyObject * -time_monotonic(PyObject *self, PyObject *unused) +time_monotonic_impl(PyModuleDef *module); + +static PyObject * +time_monotonic(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return time_monotonic_impl(module); +} + +static PyObject * +time_monotonic_impl(PyModuleDef *module) +/*[clinic end generated code: checksum=53fd6236581f1dafbec097e737359f4574eeaa55]*/ + { return pymonotonic(NULL); } +#endif /* PYMONOTONIC */ -PyDoc_STRVAR(monotonic_doc, -"monotonic() -> float\n\ -\n\ -Monotonic clock, cannot go backward."); -#endif /* PYMONOTONIC */ static PyObject* perf_counter(_Py_clock_info_t *info) @@ -1056,16 +1371,46 @@ return floattime(info); } +/*[clinic input] +time.perf_counter + +Get current value of system's performance counter. + +The units of this counter are undefined, and the counter may wrap back to zero +at some point. The performance counter may be a per-CPU value, so that +succesive invocations may not be comparable if the process has migrated to a +different CPU between calls. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_perf_counter__doc__, +"perf_counter(module)\n" +"Get current value of system\'s performance counter.\n" +"\n" +"The units of this counter are undefined, and the counter may wrap back to zero\n" +"at some point. The performance counter may be a per-CPU value, so that\n" +"succesive invocations may not be comparable if the process has migrated to a\n" +"different CPU between calls."); + +#define TIME_PERF_COUNTER_METHODDEF \ + {"perf_counter", (PyCFunction)time_perf_counter, METH_NOARGS, time_perf_counter__doc__}, + static PyObject * -time_perf_counter(PyObject *self, PyObject *unused) +time_perf_counter_impl(PyModuleDef *module); + +static PyObject * +time_perf_counter(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return time_perf_counter_impl(module); +} + +static PyObject * +time_perf_counter_impl(PyModuleDef *module) +/*[clinic end generated code: checksum=a4cc3d8bcece9369473fd07fdc4cb1d329bbf439]*/ + { return perf_counter(NULL); } -PyDoc_STRVAR(perf_counter_doc, -"perf_counter() -> float\n\ -\n\ -Performance counter for benchmarking."); static PyObject* py_process_time(_Py_clock_info_t *info) @@ -1180,28 +1525,82 @@ #endif } +/*[clinic input] +time.process_time + +Get current process time for profiling. + +The proces stime is the sum of the kernel and user-space CPU time. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_process_time__doc__, +"process_time(module)\n" +"Get current process time for profiling.\n" +"\n" +"The proces stime is the sum of the kernel and user-space CPU time."); + +#define TIME_PROCESS_TIME_METHODDEF \ + {"process_time", (PyCFunction)time_process_time, METH_NOARGS, time_process_time__doc__}, + static PyObject * -time_process_time(PyObject *self, PyObject *unused) +time_process_time_impl(PyModuleDef *module); + +static PyObject * +time_process_time(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return time_process_time_impl(module); +} + +static PyObject * +time_process_time_impl(PyModuleDef *module) +/*[clinic end generated code: checksum=38c12a5028aebe853f30b5e2eeb260e9f1a58774]*/ { return py_process_time(NULL); } -PyDoc_STRVAR(process_time_doc, -"process_time() -> float\n\ -\n\ -Process time for profiling: sum of the kernel and user-space CPU time."); +/*[clinic input] +time.get_clock_info + + name: str + / + +Get information of the specified clock. +[clinic start generated code]*/ + +PyDoc_STRVAR(time_get_clock_info__doc__, +"get_clock_info(module, name)\n" +"Get information of the specified clock."); + +#define TIME_GET_CLOCK_INFO_METHODDEF \ + {"get_clock_info", (PyCFunction)time_get_clock_info, METH_VARARGS, time_get_clock_info__doc__}, static PyObject * -time_get_clock_info(PyObject *self, PyObject *args) +time_get_clock_info_impl(PyModuleDef *module, const char *name); + +static PyObject * +time_get_clock_info(PyModuleDef *module, PyObject *args) { - char *name; + PyObject *return_value = NULL; + const char *name; + + if (!PyArg_ParseTuple(args, + "s:get_clock_info", + &name)) + goto exit; + return_value = time_get_clock_info_impl(module, name); + +exit: + return return_value; +} + +static PyObject * +time_get_clock_info_impl(PyModuleDef *module, const char *name) +/*[clinic end generated code: checksum=b36795433d54c2d786671fd8f2fbdb645d3e7dad]*/ +{ _Py_clock_info_t info; PyObject *obj = NULL, *dict, *ns; - if (!PyArg_ParseTuple(args, "s:get_clock_info", &name)) - return NULL; - #ifdef Py_DEBUG info.implementation = NULL; info.monotonic = -1; @@ -1283,11 +1682,6 @@ return NULL; } -PyDoc_STRVAR(get_clock_info_doc, -"get_clock_info(name: str) -> dict\n\ -\n\ -Get information of the specified clock."); - static void PyInit_timezone(PyObject *m) { /* This code moved from PyInit_time wholesale to allow calling it from @@ -1391,16 +1785,16 @@ static PyMethodDef time_methods[] = { - {"time", time_time, METH_NOARGS, time_doc}, + TIME_TIME_METHODDEF #ifdef PYCLOCK - {"clock", time_clock, METH_NOARGS, clock_doc}, + TIME_CLOCK_METHODDEF #endif #ifdef HAVE_CLOCK_GETTIME - {"clock_gettime", time_clock_gettime, METH_VARARGS, clock_gettime_doc}, - {"clock_settime", time_clock_settime, METH_VARARGS, clock_settime_doc}, - {"clock_getres", time_clock_getres, METH_VARARGS, clock_getres_doc}, + TIME_CLOCK_GETTIME_METHODDEF + TIME_CLOCK_SETTIME_METHODDEF + TIME_CLOCK_GETRES_METHODDEF #endif - {"sleep", time_sleep, METH_VARARGS, sleep_doc}, + TIME_SLEEP_METHODDEF {"gmtime", time_gmtime, METH_VARARGS, gmtime_doc}, {"localtime", time_localtime, METH_VARARGS, localtime_doc}, {"asctime", time_asctime, METH_VARARGS, asctime_doc}, @@ -1411,16 +1805,16 @@ #ifdef HAVE_STRFTIME {"strftime", time_strftime, METH_VARARGS, strftime_doc}, #endif - {"strptime", time_strptime, METH_VARARGS, strptime_doc}, + TIME_STRPTIME_METHODDEF #ifdef HAVE_WORKING_TZSET - {"tzset", time_tzset, METH_NOARGS, tzset_doc}, + TIME_TZSET_METHODDEF #endif #ifdef PYMONOTONIC - {"monotonic", time_monotonic, METH_NOARGS, monotonic_doc}, + TIME_MONOTONIC_METHODDEF #endif - {"process_time", time_process_time, METH_NOARGS, process_time_doc}, - {"perf_counter", time_perf_counter, METH_NOARGS, perf_counter_doc}, - {"get_clock_info", time_get_clock_info, METH_VARARGS, get_clock_info_doc}, + TIME_PROCESS_TIME_METHODDEF + TIME_PERF_COUNTER_METHODDEF + TIME_GET_CLOCK_INFO_METHODDEF {NULL, NULL} /* sentinel */ };