Issue #7989: Added pure python implementation of the datetime module. · python/cpython@cf86e36 (original) (raw)

9 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -473,6 +473,14 @@ C-API
473 473 Library
474 474 -------
475 475
476 +- Issue #7989: Added pure python implementation of the `datetime`
477 + module. The C module is renamed to `_datetime` and if available,
478 + overrides all classes defined in datetime with fast C impementation.
479 + Python implementation is based on the original python prototype for
480 + the datetime module by Tim Peters with minor modifications by the
481 + PyPy project. The test suite now tests `datetime` module with and
482 + without `_datetime` acceleration using the same test cases.
483 +
476 484 - Issue #7895: platform.mac_ver() no longer crashes after calling os.fork()
477 485
478 486 - Issue #9323: Fixed a bug in trace.py that resulted in loosing the
Original file line number Diff line number Diff line change
@@ -170,7 +170,7 @@ _symtable symtablemodule.c
170 170 #atexit atexitmodule.c # Register functions to be run at interpreter-shutdown
171 171 #_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
172 172 #_pickle _pickle.c # pickle accelerator
173 -#datetime datetimemodule.c # date/time type
173 +#_datetime _datetimemodule.c # datetime accelerator
174 174 #_bisect _bisectmodule.c # Bisection algorithms
175 175 #_heapq _heapqmodule.c # Heap queue algorithm
176 176
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
25 25 * final result fits in a C int (this can be an issue on 64-bit boxes).
26 26 */
27 27 #if SIZEOF_INT < 4
28 -# error "datetime.c requires that C int have at least 32 bits"
28 +# error "_datetime.c requires that C int have at least 32 bits"
29 29 #endif
30 30
31 31 #define MINYEAR 1
@@ -5086,7 +5086,7 @@ static PyDateTime_CAPI CAPI = {
5086 5086
5087 5087 static struct PyModuleDef datetimemodule = {
5088 5088 PyModuleDef_HEAD_INIT,
5089 -"datetime",
5089 +"_datetime",
5090 5090 "Fast implementation of the datetime type.",
5091 5091 -1,
5092 5092 module_methods,
@@ -5097,7 +5097,7 @@ static struct PyModuleDef datetimemodule = {
5097 5097 };
5098 5098
5099 5099 PyMODINIT_FUNC
5100 -PyInit_datetime(void)
5100 +PyInit__datetime(void)
5101 5101 {
5102 5102 PyObject *m; /* a module object */
5103 5103 PyObject *d; /* its dict */
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ extern PyObject* PyInit__sre(void);
43 43 extern PyObject* PyInit_parser(void);
44 44 extern PyObject* PyInit_winreg(void);
45 45 extern PyObject* PyInit__struct(void);
46 -extern PyObject* PyInit_datetime(void);
46 +extern PyObject* PyInit__datetime(void);
47 47 extern PyObject* PyInit__functools(void);
48 48 extern PyObject* PyInit__json(void);
49 49 extern PyObject* PyInit_zlib(void);
@@ -116,7 +116,7 @@ struct _inittab _PyImport_Inittab[] = {
116 116 {"parser", PyInit_parser},
117 117 {"winreg", PyInit_winreg},
118 118 {"_struct", PyInit__struct},
119 - {"datetime", PyInit_datetime},
119 + {"_datetime", PyInit__datetime},
120 120 {"_functools", PyInit__functools},
121 121 {"_json", PyInit__json},
122 122
Original file line number Diff line number Diff line change
@@ -1068,7 +1068,7 @@
1068 1068 >
1069 1069 </File>
1070 1070 <File
1071 - RelativePath="..\Modules\datetimemodule.c"
1071 + RelativePath="..\Modules\_datetimemodule.c"
1072 1072 >
1073 1073 </File>
1074 1074 <File
Original file line number Diff line number Diff line change
@@ -452,7 +452,7 @@ def detect_modules(self):
452 452 # time operations and variables
453 453 exts.append( Extension('time', ['timemodule.c', '_time.c'],
454 454 libraries=math_libs) )
455 -exts.append( Extension('datetime', ['datetimemodule.c', '_time.c'],
455 +exts.append( Extension('_datetime', ['_datetimemodule.c', '_time.c'],
456 456 libraries=math_libs) )
457 457 # fast iterator tools implemented in C
458 458 exts.append( Extension("itertools", ["itertoolsmodule.c"]) )