[issue7989] Add pure Python implementation of datetime module to CPython

Marc-Andre Lemburg report at bugs.python.org
Thu Jun 17 17:03:33 CEST 2010


Marc-Andre Lemburg <mal at egenix.com> added the comment:

Alexander Belopolsky wrote:
> 
> Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
> 
>> To avoid the wasted memory and import time, it's better to use:
>>
>> try:
>>    from _cmodule import *
>> except ImportError:
>>    from _pymodule import *
>>
> 
> .. also this makes it harder to prototype things in Python or have mixed Python/C modules.  The goal is to use Python implementation unless native implementation exists on per function/class basis.  The syntax above makes it all or nothing.

Why ?

You can have the Python parts that are used by both implementation
defined in the datetime.py module.

Alternatively, you could write:

try:
    # Use the faster C version
    from _module import *
except ImportError:
    # Use Python
    class datetime:
        ...

I find that rather ugly, though.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7989>
_______________________________________


More information about the Python-bugs-list mailing list