[issue9528] Add pure Python implementation of time module to CPython

Marc-Andre Lemburg report at bugs.python.org
Fri Aug 6 09:44:19 CEST 2010

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

> I believe _time module should become the home of the gettimeofday() method and pure python implementation of time.time() will be
> def time()
>    s, us = _time.gettimeofday()
>    return s + 1e-6 * us
> Similarly time.sleep() can be implemented in terms of lower level POSIX nanosleep() method.
> Lower level localtime() function can provide access to tm_zone and tm_gmtoff members of struct tm (where available) without concerns about backward compatibility.

Just for understanding:

Why are you calling the ticket "*Add* pure Python implementation of time
module to CPython" when you appear to be after *replacing* the C
implementation of the time module with a Python version ?

The same argument as for the datetime module applies: you can *add*
a compatible Python version of the same module for other Python
implementations to use, but undoing the work that has been done
in order to provide a faster implementation of the Python version
is a no-go.

Both datetime and time module functionalities need to be as fast as
possible, since they are used a lot in Python code. That was the
main reason for having a C implementation of the datetime and time

Python C function calls are still a lot faster than Python function
calls. You can't just replace a C function call with a Python one
without taking this into account. For these modules, it's not just
the API compatibility that matters, performance is just as
relevant and I don't really see a point in making CPython slower
just to make maintenance of stdlib modules that are not needed by
CPython easier.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list