Alexander Belopolsky wrote:
One of the common complains about working with time values in Python, is that it some functionality is available in time module, some in datetime module and some in both.
I propose a series of steps towards improving this situation.
- Create posixtime.py initially containing just "from time import *"
- Add python implementation of time.* functions to posixtime.py.
- Rename time module to _posixtime and add time.py with a deprecation
warning and "from _posixtime import *".
Note that #2 may require to move some code from timemodule.c to datetimemodule.c, but at the binary level code compiled from these files is already linked together in datetimemodule. Moving the necessary code to datetime.c will help to eliminate current circular dependency between time and datetime.
I'm not sure I understand the point in renaming the module.
Note that the time module works based on Unix ticks (seconds since the Unix Epoch), while the datetime module works based on its own set of types.
As such, the two are different implementations for managing date/time. Mixing them won't make things easier to understand. The time module is very close to the C lib API, while the datetime module focuses more on date/time storage in a more accessible.
I agree on one point, though: the shared C APIs for getting the current time would be better put into a separate C extension which both can then load without creating circular references, e.g. _getcurrenttime.c.