[issue7989] Transition time/datetime C modules to Python
report at bugs.python.org
Mon Jun 7 19:17:08 CEST 2010
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
For the datetime module there are also a few more subtle issues that would make it difficult to make a hybrid C/Python implementation. The problem is that unlike the time module where most of the functionality is implemented in module level functions, datetime functionality is entirely in class methods.
One may suggest to use inheritance and derive datetime classes from those implemented in _datetime.c, but this will not work because for example datetime + timedelta will return a _datetime class unless __add__ is overridden in Python. There is another even less obvious issue with inheriting from datetime classes: see issue #5516.
Therefore, it looks like there are only two choices:
1. Replicate all functionality in both _datetime.c and datetime.py and thus double the cost of implementing new features in CPython. (OK, maybe not double because Python development is easier than C, but increase instead of decrease.)
2. Incur a performance penalty in every method because every C call wil have to be wrapped in Python.
Another -1 from me.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list