Message 107272 - Python tracker (original) (raw)
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:
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.)
Incur a performance penalty in every method because every C call wil have to be wrapped in Python.
Another -1 from me.