Skip to content

Commit

Permalink
Issue #7989: Added pure python implementation of the datetime module.
Browse files Browse the repository at this point in the history
  • Loading branch information
abalkin committed Jul 23, 2010
1 parent c2721b0 commit cf86e36
Show file tree
Hide file tree
Showing 9 changed files with 5,813 additions and 3,670 deletions.
2,087 changes: 2,087 additions & 0 deletions Lib/datetime.py

Large diffs are not rendered by default.

3,674 changes: 3,674 additions & 0 deletions Lib/test/datetimetester.py

Large diffs are not rendered by default.

3,698 changes: 36 additions & 3,662 deletions Lib/test/test_datetime.py

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Misc/NEWS
Expand Up @@ -473,6 +473,14 @@ C-API
Library
-------

- Issue #7989: Added pure python implementation of the `datetime`
module. The C module is renamed to `_datetime` and if available,
overrides all classes defined in datetime with fast C impementation.
Python implementation is based on the original python prototype for
the datetime module by Tim Peters with minor modifications by the
PyPy project. The test suite now tests `datetime` module with and
without `_datetime` acceleration using the same test cases.

- Issue #7895: platform.mac_ver() no longer crashes after calling os.fork()

- Issue #9323: Fixed a bug in trace.py that resulted in loosing the
Expand Down
2 changes: 1 addition & 1 deletion Modules/Setup.dist
Expand Up @@ -170,7 +170,7 @@ _symtable symtablemodule.c
#atexit atexitmodule.c # Register functions to be run at interpreter-shutdown
#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
#_pickle _pickle.c # pickle accelerator
#datetime datetimemodule.c # date/time type
#_datetime _datetimemodule.c # datetime accelerator
#_bisect _bisectmodule.c # Bisection algorithms
#_heapq _heapqmodule.c # Heap queue algorithm

Expand Down
6 changes: 3 additions & 3 deletions Modules/datetimemodule.c → Modules/_datetimemodule.c
Expand Up @@ -25,7 +25,7 @@
* final result fits in a C int (this can be an issue on 64-bit boxes).
*/
#if SIZEOF_INT < 4
# error "datetime.c requires that C int have at least 32 bits"
# error "_datetime.c requires that C int have at least 32 bits"
#endif

#define MINYEAR 1
Expand Down Expand Up @@ -5086,7 +5086,7 @@ static PyDateTime_CAPI CAPI = {

static struct PyModuleDef datetimemodule = {
PyModuleDef_HEAD_INIT,
"datetime",
"_datetime",
"Fast implementation of the datetime type.",
-1,
module_methods,
Expand All @@ -5097,7 +5097,7 @@ static struct PyModuleDef datetimemodule = {
};

PyMODINIT_FUNC
PyInit_datetime(void)
PyInit__datetime(void)
{
PyObject *m; /* a module object */
PyObject *d; /* its dict */
Expand Down
4 changes: 2 additions & 2 deletions PC/config.c
Expand Up @@ -43,7 +43,7 @@ extern PyObject* PyInit__sre(void);
extern PyObject* PyInit_parser(void);
extern PyObject* PyInit_winreg(void);
extern PyObject* PyInit__struct(void);
extern PyObject* PyInit_datetime(void);
extern PyObject* PyInit__datetime(void);
extern PyObject* PyInit__functools(void);
extern PyObject* PyInit__json(void);
extern PyObject* PyInit_zlib(void);
Expand Down Expand Up @@ -116,7 +116,7 @@ struct _inittab _PyImport_Inittab[] = {
{"parser", PyInit_parser},
{"winreg", PyInit_winreg},
{"_struct", PyInit__struct},
{"datetime", PyInit_datetime},
{"_datetime", PyInit__datetime},
{"_functools", PyInit__functools},
{"_json", PyInit__json},

Expand Down
2 changes: 1 addition & 1 deletion PCbuild/pythoncore.vcproj
Expand Up @@ -1068,7 +1068,7 @@
>
</File>
<File
RelativePath="..\Modules\datetimemodule.c"
RelativePath="..\Modules\_datetimemodule.c"
>
</File>
<File
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -452,7 +452,7 @@ def detect_modules(self):
# time operations and variables
exts.append( Extension('time', ['timemodule.c', '_time.c'],
libraries=math_libs) )
exts.append( Extension('datetime', ['datetimemodule.c', '_time.c'],
exts.append( Extension('_datetime', ['_datetimemodule.c', '_time.c'],
libraries=math_libs) )
# fast iterator tools implemented in C
exts.append( Extension("itertools", ["itertoolsmodule.c"]) )
Expand Down

0 comments on commit cf86e36

Please sign in to comment.