cpython: f8409b3d6449 (original) (raw)

--- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -808,13 +808,16 @@ as internal buffering of data. Availability: Unix. -.. function:: fstat(fd) +.. function:: fstat(fd, timestamp=None) Return status for file descriptor fd, like :func:~os.stat. Availability: Unix, Windows. -.. function:: fstatat(dirfd, path, flags=0)

+ +.. function:: fstatat(dirfd, path, flags=0, timestamp="float") Like :func:stat but if path is relative, it is taken as relative to dirfd. flags is optional and may be 0 or :data:AT_SYMLINK_NOFOLLOW. @@ -1696,7 +1699,7 @@ Files and Directories .. versionadded:: 3.3 -.. function:: lstat(path) +.. function:: lstat(path, timestamp=None) Perform the equivalent of an :c:func:lstat system call on the given path. Similar to :func:~os.stat, but does not follow symbolic links. On @@ -1706,6 +1709,9 @@ Files and Directories .. versionchanged:: 3.2 Added support for Windows 6.0 (Vista) symbolic links.

+ .. function:: lutimes(path[, times]) @@ -1969,7 +1975,7 @@ Files and Directories .. versionadded:: 3.3 -.. function:: stat(path) +.. function:: stat(path, timestamp=None) Perform the equivalent of a :c:func:stat system call on the given path. (This function follows symlinks; to stat a symlink use :func:lstat.) @@ -1989,6 +1995,11 @@ Files and Directories * :attr:st_ctime - platform dependent; time of most recent metadata change on Unix, or the time of creation on Windows)

@@ -2044,6 +2055,9 @@ Files and Directories Availability: Unix, Windows.

+ .. function:: stat_float_times([newvalue]) @@ -2069,6 +2083,9 @@ Files and Directories are processed, this application should turn the feature off until the library has been corrected.

+ .. function:: statvfs(path) @@ -2859,27 +2876,39 @@ written in Python, such as a mail server with :const:P_NOWAIT return suitable process handles. -.. function:: wait3([options]) +.. function:: wait3(options[, timestamp=float]) Similar to :func:waitpid, except no process id argument is given and a 3-element tuple containing the child's process id, exit status indication, and resource usage information is returned. Refer to :mod:resource.[](#l1.91) :func:getrusage for details on resource usage information. The option argument is the same as that provided to :func:waitpid and :func:wait4.

- -.. function:: wait4(pid, options)

+ + +.. function:: wait4(pid, options[, timestamp=float]) Similar to :func:waitpid, except a 3-element tuple, containing the child's process id, exit status indication, and resource usage information is returned. Refer to :mod:resource.\ :func:getrusage for details on resource usage information. The arguments to :func:wait4 are the same as those provided to :func:waitpid.

+ .. data:: WNOHANG

--- a/Doc/library/time.rst +++ b/Doc/library/time.rst @@ -95,6 +95,14 @@ An explanation of some terminology and c | local time | | | +-------------------------+-------------------------+-------------------------+ +.. _timestamp-types: + +* Python supports the following timestamp types: +

-.. function:: clock() +.. function:: clock(timestamp=float) .. index:: single: CPU time @@ -136,16 +144,27 @@ The module defines the following functio :c:func:QueryPerformanceCounter. The resolution is typically better than one microsecond.

-.. function:: clock_getres(clk_id)

+ + +.. function:: clock_getres(clk_id, timestamp=float) Return the resolution (precision) of the specified clock clk_id.

.. versionadded:: 3.3 -.. function:: clock_gettime(clk_id) +.. function:: clock_gettime(clk_id, timestamp=float) Return the time of the specified clock clk_id.

@@ -214,19 +233,22 @@ The module defines the following functio flag is set to 1 when DST applies to the given time. -.. function:: mktime(t) +.. function:: mktime(t, timestamp=float) This is the inverse function of :func:localtime. Its argument is the :class:struct_time or full 9-tuple (since the dst flag is needed; use -1 as the dst flag if it is unknown) which expresses the time in local time, not

-.. function:: monotonic() +.. function:: monotonic(timestamp=float) Monotonic clock. The reference point of the returned value is undefined so only the difference of consecutive calls is valid. @@ -440,15 +462,20 @@ The module defines the following functio :exc:TypeError is raised. -.. function:: time() +.. function:: time(timestamp=float)

+ .. data:: timezone @@ -546,13 +573,16 @@ The module defines the following functio ('EET', 'EEST') -.. function:: wallclock() +.. function:: wallclock(timestamp=float) .. index:: single: Wallclock single: benchmarking Return the current time in fractions of a second to the system's best ability.

--- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -270,6 +270,42 @@ new, more precise information:: '<function C.D.meth at 0x7f46b9fe31e0>' +PEP 410: Use decimal.Decimal type for timestamps +================================================ + +:pep:410 - Use decimal.Decimal type for timestamps

+:class:decimal.Decimal supports a resolution of a nanosecond (10^-9) +resolution, whereas :class:float has only a resolution of a microsecond +(10^-6) in common cases. See the list of available :ref:timestamp types[](#l3.26) +<timestamp-types>. + +Example:: +

+ +:func:os.stat_float_times has been deprecated, use timestamp argument of +os.stat instead. + + Other Language Changes ======================

--- a/Include/pytime.h +++ b/Include/pytime.h @@ -2,7 +2,8 @@ #ifndef Py_PYTIME_H #define Py_PYTIME_H -#include "pyconfig.h" /* include for defines */ +#include "pyport.h" +#include "object.h" /************************************************************************** Symbols and macros to supply platform-independent interfaces to time related @@ -37,6 +38,31 @@ do { [](#l4.13) ((tv_end.tv_sec - tv_start.tv_sec) + [](#l4.14) (tv_end.tv_usec - tv_start.tv_usec) * 0.000001) +#if defined(HAVE_LONG_LONG) +typedef unsigned PY_LONG_LONG _PyTime_fraction_t; +#else +typedef size_t _PyTime_fraction_t; +#endif + +typedef struct +{

+} _PyTime_t; + +/* Similar to POSIX gettimeofday. If system gettimeofday

+/* Convert a timestamp structure to the specified timestamp type. +

/* Dummy to force linking. */ PyAPI_FUNC(void) _PyTime_Init(void);

--- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -2,6 +2,7 @@

does add tests for a few functions which have been determined to be more

portable than they had been thought to be.

+import decimal import os import errno import unittest @@ -238,6 +239,36 @@ class StatAttributeTests(unittest.TestCa warnings.simplefilter("ignore", DeprecationWarning) self.check_stat_attributes(fname)

+

+

+

+ def test_statvfs_attributes(self): if not hasattr(os, "statvfs"): return

--- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -1,10 +1,10 @@ +import locale +import platform +import sys +import sysconfig from test import support import time import unittest -import locale -import sysconfig -import sys -import platform

Max year is only limited by the size of C int.

SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4 @@ -345,6 +345,31 @@ class TimeTestCase(unittest.TestCase): self.assertGreater(t2, t1) self.assertAlmostEqual(dt, 0.1, delta=0.2)

+

+

+ def test_wallclock(self): t1 = time.wallclock() t2 = time.wallclock()

--- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1702,6 +1702,12 @@ stat_float_times(PyObject* self, PyObjec int newval = -1; if (!PyArg_ParseTuple(args, "|i:stat_float_times", &newval)) return NULL;

+ if (newval == -1) /* Return old value / return PyBool_FromLong(_stat_float_times); @@ -1711,9 +1717,12 @@ stat_float_times(PyObject self, PyObjec } static void -fill_time(PyObject *v, int index, time_t sec, unsigned long nsec) +fill_time(PyObject *v, int index, time_t sec, unsigned long nsec,

{ PyObject *fval,*ival;

+ #if SIZEOF_TIME_T > SIZEOF_LONG ival = PyLong_FromLongLong((PY_LONG_LONG)sec); #else @@ -1721,9 +1730,21 @@ fill_time(PyObject *v, int index, time_t #endif if (!ival) return;

+#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME

+#endif + PyObject v = PyStructSequence_New(&StatResultType); if (v == NULL) return NULL; @@ -1768,20 +1794,24 @@ static PyObject ansec = st->st_atim.tv_nsec; mnsec = st->st_mtim.tv_nsec; cnsec = st->st_ctim.tv_nsec;

#elif defined(HAVE_STAT_TV_NSEC2) ansec = st->st_atimespec.tv_nsec; mnsec = st->st_mtimespec.tv_nsec; cnsec = st->st_ctimespec.tv_nsec;

#elif defined(HAVE_STAT_NSEC) ansec = st->st_atime_nsec; mnsec = st->st_mtime_nsec; cnsec = st->st_ctime_nsec;

#else ansec = mnsec = cnsec = 0; -#endif

+#endif

#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX, @@ -1801,21 +1831,26 @@ static PyObject* #endif #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME {

#ifdef HAVE_STAT_TV_NSEC2

#else

-#endif

+#endif

#endif #ifdef HAVE_STRUCT_STAT_ST_FLAGS @@ -1832,7 +1867,7 @@ static PyObject* } static PyObject * -posix_do_stat(PyObject *self, PyObject *args, +posix_do_stat(PyObject *self, PyObject *args, PyObject *kw, char *format, #ifdef __VMS int (*statfunc)(const char *, STRUCT_STAT *, ...), @@ -1842,15 +1877,18 @@ posix_do_stat(PyObject *self, PyObject * char *wformat, int (*wstatfunc)(const wchar_t *, STRUCT_STAT *)) {

#ifdef MS_WINDOWS PyObject *po;

@@ -1861,15 +1899,17 @@ posix_do_stat(PyObject *self, PyObject * if (res != 0) return win32_error_object("stat", po);

+#endif +

#ifdef MS_WINDOWS if (win32_warn_bytes_api()) { @@ -1890,7 +1930,7 @@ posix_do_stat(PyObject *self, PyObject * #endif } else

Py_DECREF(opath); return result; @@ -3381,16 +3421,16 @@ posix_rmdir(PyObject *self, PyObject *ar PyDoc_STRVAR(posix_stat__doc__, -"stat(path) -> stat result\n\n[](#l7.205) +"stat(path, timestamp=None) -> stat result\n\n[](#l7.206) Perform a stat system call on the given path."); static PyObject * -posix_stat(PyObject *self, PyObject *args) +posix_stat(PyObject *self, PyObject *args, PyObject *kw) { #ifdef MS_WINDOWS

#else

#endif } @@ -6118,11 +6158,12 @@ posix_setgroups(PyObject *self, PyObject #if defined(HAVE_WAIT3) || defined(HAVE_WAIT4) static PyObject * -wait_helper(pid_t pid, int status, struct rusage *ru) +wait_helper(pid_t pid, int status, struct rusage *ru, PyObject *timestamp) { PyObject *result; static PyObject *struct_rusage; _Py_IDENTIFIER(struct_rusage);

if (pid == -1) return posix_error(); @@ -6146,10 +6187,17 @@ wait_helper(pid_t pid, int status, struc #define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001) #endif

+

#define SET_INT(result, index, value)[](#l7.253) PyStructSequence_SET_ITEM(result, index, PyLong_FromLong(value)) SET_INT(result, 2, ru->ru_maxrss); @@ -6179,51 +6227,55 @@ wait_helper(pid_t pid, int status, struc #ifdef HAVE_WAIT3 PyDoc_STRVAR(posix_wait3__doc__, -"wait3(options) -> (pid, status, rusage)\n\n[](#l7.260) +"wait3(options[, timestamp=float]) -> (pid, status, rusage)\n\n[](#l7.261) Wait for completion of a child process."); static PyObject * -posix_wait3(PyObject *self, PyObject *args) -{ +posix_wait3(PyObject *self, PyObject *args, PyObject *kwargs) +{

+

Py_BEGIN_ALLOW_THREADS pid = wait3(&status, options, &ru); Py_END_ALLOW_THREADS

} #endif /* HAVE_WAIT3 */ #ifdef HAVE_WAIT4 PyDoc_STRVAR(posix_wait4__doc__, -"wait4(pid, options) -> (pid, status, rusage)\n\n[](#l7.293) +"wait4(pid, options[, timestamp=float]) -> (pid, status, rusage)\n\n[](#l7.294) Wait for completion of a given child process."); static PyObject * -posix_wait4(PyObject *self, PyObject *args) -{ +posix_wait4(PyObject *self, PyObject *args, PyObject *kwargs) +{

+

Py_BEGIN_ALLOW_THREADS pid = wait4(pid, &status, options, &ru); Py_END_ALLOW_THREADS

} #endif /* HAVE_WAIT4 */ @@ -6350,20 +6402,20 @@ posix_wait(PyObject *self, PyObject *noa PyDoc_STRVAR(posix_lstat__doc__, -"lstat(path) -> stat result\n\n[](#l7.328) +"lstat(path, timestamp=None) -> stat result\n\n[](#l7.329) Like stat(path), but do not follow symbolic links."); static PyObject * -posix_lstat(PyObject *self, PyObject *args) +posix_lstat(PyObject *self, PyObject *args, PyObject *kw) { #ifdef HAVE_LSTAT

#else /* !HAVE_LSTAT */ #ifdef MS_WINDOWS

#else

#endif #endif /* !HAVE_LSTAT */ } @@ -7322,16 +7374,19 @@ done: #endif PyDoc_STRVAR(posix_fstat__doc__, -"fstat(fd) -> stat result\n\n[](#l7.354) +"fstat(fd, timestamp=None) -> stat result\n\n[](#l7.355) Like stat(), but for an open file descriptor."); static PyObject * -posix_fstat(PyObject *self, PyObject *args) -{ +posix_fstat(PyObject *self, PyObject *args, PyObject *kwargs) +{

#ifdef __VMS /* on OpenVMS we must ensure that all bytes are written to the file */ @@ -7350,7 +7405,7 @@ posix_fstat(PyObject *self, PyObject *ar #endif }

} PyDoc_STRVAR(posix_isatty__doc__, @@ -9634,22 +9689,25 @@ posix_fchownat(PyObject *self, PyObject #ifdef HAVE_FSTATAT PyDoc_STRVAR(posix_fstatat__doc__, -"fstatat(dirfd, path, flags=0) -> stat result\n\n[](#l7.387) +"fstatat(dirfd, path, flags=0, timestamp=None) -> stat result\n\n[](#l7.388) Like stat() but if path is relative, it is taken as relative to dirfd.\n[](#l7.389) flags is optional and may be 0 or AT_SYMLINK_NOFOLLOW.\n[](#l7.390) If path is relative and dirfd is the special value AT_FDCWD, then path\n[](#l7.391) is interpreted relative to the current working directory."); static PyObject * -posix_fstatat(PyObject *self, PyObject *args) -{ +posix_fstatat(PyObject *self, PyObject *args, PyObject *kwargs) +{

+

} #endif @@ -10524,7 +10582,7 @@ static PyMethodDef posix_methods[] = { #ifdef HAVE_FDOPENDIR {"flistdir", posix_flistdir, METH_VARARGS, posix_flistdir__doc__}, #endif

#ifdef HAVE_NICE {"nice", posix_nice, METH_VARARGS, posix_nice__doc__}, @@ -10544,7 +10602,8 @@ static PyMethodDef posix_methods[] = { {"rename", posix_rename, METH_VARARGS, posix_rename__doc__}, {"replace", posix_replace, METH_VARARGS, posix_replace__doc__}, {"rmdir", posix_rmdir, METH_VARARGS, posix_rmdir__doc__},

#if defined(HAVE_SYMLINK) && !defined(MS_WINDOWS) {"symlink", posix_symlink, METH_VARARGS, posix_symlink__doc__}, @@ -10705,10 +10764,12 @@ static PyMethodDef posix_methods[] = { {"wait", posix_wait, METH_NOARGS, posix_wait__doc__}, #endif /* HAVE_WAIT */ #ifdef HAVE_WAIT3

#endif /* HAVE_WAIT3 */ #ifdef HAVE_WAIT4

#endif /* HAVE_WAIT4 */ #if defined(HAVE_WAITID) && !defined(APPLE) {"waitid", posix_waitid, METH_VARARGS, posix_waitid__doc__}, @@ -10759,7 +10820,8 @@ static PyMethodDef posix_methods[] = { {"sendfile", (PyCFunction)posix_sendfile, METH_VARARGS | METH_KEYWORDS, posix_sendfile__doc__}, #endif

#ifdef HAVE_PIPE {"pipe", posix_pipe, METH_NOARGS, posix_pipe__doc__}, @@ -10894,7 +10956,8 @@ static PyMethodDef posix_methods[] = { {"fchownat", posix_fchownat, METH_VARARGS, posix_fchownat__doc__}, #endif /* HAVE_FCHOWNAT */ #ifdef HAVE_FSTATAT

#endif #ifdef HAVE_FUTIMESAT {"futimesat", posix_futimesat, METH_VARARGS, posix_futimesat__doc__},

--- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -40,24 +40,30 @@ #include <sys/time.h> #endif +#if (defined(MS_WINDOWS) && !defined(BORLANDC)) || defined(HAVE_CLOCK) +# define HAVE_PYCLOCK +#endif + /* Forward declarations */ static int floatsleep(double); -static double floattime(void); static PyObject * -time_time(PyObject *self, PyObject *unused) +time_time(PyObject *self, PyObject *args, PyObject *kwargs) {

+

+

} PyDoc_STRVAR(time_doc, -"time() -> floating point number\n[](#l8.38) +"time(timestamp=float) -> floating point number\n[](#l8.39) \n[](#l8.40) Return the current time in seconds since the Epoch.\n[](#l8.41) Fractions of a second may be present if the system clock provides them."); @@ -72,65 +78,91 @@ Fractions of a second may be present if #endif #endif -static PyObject * -pyclock(void) +static int +pyclock(_PyTime_t *ts) {

} #endif /* HAVE_CLOCK / #if defined(MS_WINDOWS) && !defined(BORLANDC) / Win32 has better clock replacement; we have our own version, due to Mark Hammond and Tim Peters */ -static PyObject * -win32_clock(int fallback) +static int +win32_clock(_PyTime_t *ts, int fallback) { static LONGLONG cpu_frequency = 0;

if (cpu_frequency == 0) { LARGE_INTEGER freq; QueryPerformanceCounter(&now);

+

} #endif #if (defined(MS_WINDOWS) && !defined(BORLANDC)) || defined(HAVE_CLOCK) static PyObject * -time_clock(PyObject *self, PyObject *unused) +time_clock(PyObject *self, PyObject *args, PyObject *kwargs) {

+

+ #if defined(MS_WINDOWS) && !defined(BORLANDC)

#else

#endif

} PyDoc_STRVAR(clock_doc, -"clock() -> floating point number\n[](#l8.152) +"clock(timestamp=float) -> floating point number\n[](#l8.153) \n[](#l8.154) Return the CPU time or real time since the start of the process or since\n[](#l8.155) the first call to clock(). This has as much precision as the system\n[](#l8.156) @@ -139,13 +171,17 @@ records."); #ifdef HAVE_CLOCK_GETTIME static PyObject * -time_clock_gettime(PyObject *self, PyObject *args) +time_clock_gettime(PyObject *self, PyObject *args, PyObject *kwargs) {

ret = clock_gettime((clockid_t)clk_id, &tp); @@ -153,25 +189,31 @@ time_clock_gettime(PyObject *self, PyObj PyErr_SetFromErrno(PyExc_IOError); return NULL; } -

} PyDoc_STRVAR(clock_gettime_doc, -"clock_gettime(clk_id) -> floating point number\n[](#l8.190) +"clock_gettime(clk_id, timestamp=float) -> floating point number\n[](#l8.191) \n[](#l8.192) Return the time of the specified clock clk_id."); #endif #ifdef HAVE_CLOCK_GETRES static PyObject * -time_clock_getres(PyObject *self, PyObject *args) +time_clock_getres(PyObject *self, PyObject *args, PyObject *kwargs) {

ret = clock_getres((clockid_t)clk_id, &tp); @@ -179,12 +221,14 @@ time_clock_getres(PyObject *self, PyObje PyErr_SetFromErrno(PyExc_IOError); return NULL; } -

} PyDoc_STRVAR(clock_getres_doc, -"clock_getres(clk_id) -> floating point number\n[](#l8.227) +"clock_getres(clk_id, timestamp=float) -> floating point number\n[](#l8.228) \n[](#l8.229) Return the resolution (precision) of the specified clock clk_id."); #endif @@ -707,10 +751,19 @@ not present, current time as returned by #ifdef HAVE_MKTIME static PyObject * -time_mktime(PyObject *self, PyObject *tup) +time_mktime(PyObject *self, PyObject *args, PyObject *kwargs) {

+

+ if (!gettmarg(tup, &buf)) return NULL; buf.tm_wday = -1; /* sentinel; original value ignored */ @@ -722,7 +775,10 @@ time_mktime(PyObject *self, PyObject *tu "mktime argument out of range"); return NULL; }

} PyDoc_STRVAR(mktime_doc, @@ -768,12 +824,14 @@ the local timezone used by methods such should not be relied on."); #endif /* HAVE_WORKING_TZSET */ -static PyObject * -time_wallclock(PyObject *self, PyObject *unused) +static int +pywallclock(_PyTime_t *ts) { #if defined(MS_WINDOWS) && !defined(BORLANDC)

-#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)

+#else + +#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) static int clk_index = 0; clockid_t clk_ids[] = { #ifdef CLOCK_MONOTONIC_RAW @@ -793,20 +851,41 @@ time_wallclock(PyObject *self, PyObject clockid_t clk_id = clk_ids[clk_index]; ret = clock_gettime(clk_id, &tp); if (ret == 0)

clk_index++; if (Py_ARRAY_LENGTH(clk_ids) <= clk_index) clk_index = -1; }

-#else

+#endif /* defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) */ +

#endif } +static PyObject * +time_wallclock(PyObject *self, PyObject *args, PyObject *kwargs) +{

+

+} + PyDoc_STRVAR(wallclock_doc, -"wallclock() -> float\n[](#l8.326) +"wallclock(timestamp=float)\n[](#l8.327) \n[](#l8.328) Return the current time in fractions of a second to the system's best\n[](#l8.329) ability. Use this when the most accurate representation of wall-clock is\n[](#l8.330) @@ -821,11 +900,11 @@ calls is valid."); #ifdef HAVE_PYTIME_MONOTONIC static PyObject * -time_monotonic(PyObject *self, PyObject *unused) +time_monotonic(PyObject *self, PyObject *args, PyObject *kwargs) { -#if defined(MS_WINDOWS) && !defined(BORLANDC)

-#else

+#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) static int clk_index = 0; clockid_t clk_ids[] = { #ifdef CLOCK_MONOTONIC_RAW @@ -835,12 +914,28 @@ time_monotonic(PyObject *self, PyObject }; int ret; struct timespec tp; +#endif

+ +#if defined(MS_WINDOWS) && !defined(BORLANDC)

+#else while (0 <= clk_index) { clockid_t clk_id = clk_ids[clk_index]; ret = clock_gettime(clk_id, &tp); if (ret == 0)

clk_index++; if (Py_ARRAY_LENGTH(clk_ids) <= clk_index) @@ -968,15 +1063,19 @@ PyInit_timezone(PyObject *m) { static PyMethodDef time_methods[] = {

-#if (defined(MS_WINDOWS) && !defined(BORLANDC)) || defined(HAVE_CLOCK)

+#ifdef HAVE_PYCLOCK

#endif #ifdef HAVE_CLOCK_GETTIME

#endif #ifdef HAVE_CLOCK_GETRES

#endif {"sleep", time_sleep, METH_VARARGS, sleep_doc}, {"gmtime", time_gmtime, METH_VARARGS, gmtime_doc}, @@ -984,10 +1083,12 @@ static PyMethodDef time_methods[] = { {"asctime", time_asctime, METH_VARARGS, asctime_doc}, {"ctime", time_ctime, METH_VARARGS, ctime_doc}, #ifdef HAVE_MKTIME

#endif #ifdef HAVE_PYTIME_MONOTONIC

#endif #ifdef HAVE_STRFTIME {"strftime", time_strftime, METH_VARARGS, strftime_doc}, @@ -996,7 +1097,8 @@ static PyMethodDef time_methods[] = { #ifdef HAVE_WORKING_TZSET {"tzset", time_tzset, METH_NOARGS, tzset_doc}, #endif

-} - - /* Implement floatsleep() for various platforms. When interrupted (or when another error occurs), return -1 and set an exception; else return 0. */

--- a/Python/pytime.c +++ b/Python/pytime.c @@ -18,24 +18,36 @@ extern int ftime(struct timeb *); #endif +#define MICROSECONDS 1000000 + void -_PyTime_gettimeofday(_PyTime_timeval *tp) +_PyTime_get(_PyTime_t *ts) { #ifdef MS_WINDOWS FILETIME system_time; ULARGE_INTEGER large;

GetSystemTimeAsFileTime(&system_time); large.u.LowPart = system_time.dwLowDateTime; large.u.HighPart = system_time.dwHighDateTime;

#else + +#ifdef HAVE_GETTIMEOFDAY

+#endif +#if defined(HAVE_FTIME)

+#endif + /* There are three ways to get the time: (1) gettimeofday() -- resolution in microseconds (2) ftime() -- resolution in milliseconds @@ -47,30 +59,325 @@ void #ifdef HAVE_GETTIMEOFDAY #ifdef GETTIMEOFDAY_NO_TZ

#else /* !GETTIMEOFDAY_NO_TZ */

+#endif /* !GETTIMEOFDAY_NO_TZ */

-#endif /* !GETTIMEOFDAY_NO_TZ */

#endif /* !HAVE_GETTIMEOFDAY */ #if defined(HAVE_FTIME)

#else /* !HAVE_FTIME */

#endif /* !HAVE_FTIME / #endif / MS_WINDOWS */ } void +_PyTime_gettimeofday(_PyTime_timeval *tv) +{

+

+} + +static PyObject* +_PyLong_FromTime_t(time_t value) +{ +#if SIZEOF_TIME_T <= SIZEOF_LONG

+#else

+#endif +} + +#if defined(HAVE_LONG_LONG) +# define _PyLong_FromTimeFraction_t PyLong_FromLongLong +#else +# define _PyLong_FromTimeFraction_t PyLong_FromSize_t +#endif + +/* Convert a timestamp to a PyFloat object / +static PyObject +_PyTime_AsFloat(_PyTime_t *ts) +{

+} + +/* Convert a timestamp to a PyLong object / +static PyObject +_PyTime_AsLong(_PyTime_t *ts) +{

+

+} + +/* Convert a timestamp to a decimal.Decimal object / +static PyObject +_PyTime_AsDecimal(_PyTime_t *ts) +{

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ +error:

+} + +PyObject* +_PyTime_Convert(_PyTime_t *ts, PyObject *format) +{

+

+

+

+

+} + +void _PyTime_Init() { /* Do nothing. Needed to force linking. */