Add pure Python implementation of time module to CPython #53737
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee = 'https://github.com/abalkin' closed_at = <Date 2010-12-01.18:43:25.796> created_at = <Date 2010-08-06.04:33:20.317> labels = ['extension-modules', 'type-feature', 'library'] title = 'Add pure Python implementation of time module to CPython' updated_at = <Date 2012-03-22.10:13:40.766> user = 'https://github.com/abalkin'
activity = <Date 2012-03-22.10:13:40.766> actor = 'anacrolix' assignee = 'belopolsky' closed = True closed_date = <Date 2010-12-01.18:43:25.796> closer = 'belopolsky' components = ['Extension Modules', 'Library (Lib)'] creation = <Date 2010-08-06.04:33:20.317> creator = 'belopolsky' dependencies =  files =  hgrepos =  issue_num = 9528 keywords =  message_count = 13.0 messages = ['113073', '113084', '113085', '113103', '113742', '118023', '123003', '141874', '141875', '141877', '141878', '141880', '141911'] nosy_count = 18.0 nosy_names = ['lemburg', 'tim.peters', 'brett.cannon', 'rhettinger', 'amaury.forgeotdarc', 'mark.dickinson', 'davidfraser', 'belopolsky', 'pitrou', 'vstinner', 'techtonik', 'giampaolo.rodola', 'eric.araujo', 'r.david.murray', 'brian.curtin', 'daniel.urban', 'alanjds', 'anacrolix'] pr_nums =  priority = 'normal' resolution = 'rejected' stage = 'resolved' status = 'closed' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue9528' versions = ['Python 3.3']
The text was updated successfully, but these errors were encountered:
The original RFE at bpo-7989 was:
See msg99774. I have changed bpo-7989 to cover datetime only because I argued that as a thin wrapper around C library calls, this module is an exception to the general rule that pure python implementations are a good idea. See msg107303.
No I realize that in order to break circular dependency between time and datetime modules, it will be helpful to create an _time module that would provide lower than time module access to system facilities and datetime and time modules would be use _time module to implement higher level interfaces either in C or in Python.
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
The same argument as for the datetime module applies: you can *add*
Both datetime and time module functionalities need to be as fast as
Python C function calls are still a lot faster than Python function
On Fri, Aug 6, 2010 at 3:44 AM, Marc-Andre Lemburg
I have deliberately made the title similar to bpo-7989 so that it is
The current situation has several problems:
I completely agree. Actually my outline in the first post is
Absolutely. In fact this proposal will open the door to implementing
BTW, this brings a point that I think I missed when I introduced
Brett addressed this point responding to my own concerns in msg107295
Why not introducing a new function in time module? Other people may benefit from this.
Why not creating a new function giving access to all tm attributes? Eg. time.localtime_gmaware()?
What about time_strftime()? It is 170 lines long: will it be moved to _basictime.c? You have to keep the code filling the "struct tm" structure in (_)timemodule.c.
On Thu, Aug 12, 2010 at 10:26 PM, STINNER Victor <email@example.com> wrote:
I agree. See bpo-9079.
We can do that. I'll experiment with this approach within bpo-9527.
No, I don't want time_strftime in _basictime. I want
@Haypo: Because it affects version 2.7 too.
@victor: Even since we will not backport any modules to Python 2.7, is not worth to sign that this affects it too? Even wontfix or rejected, it affects, does not?
Have I made something wrong? Sorry to be so newbie about this.
Is not easy to change/extend datetime, as stated by several other before. Searching the bugs for 2.x only does not shows that someone else already care about this issue AND that it exists at 2.x too.
I am getting a hard time trying to do some BDD with c-based datetime because I cannot mock it easily to force datetime.datetime.now() to return a desired value, making almost impossible to test time-based code, like the accounting system that I am refactoring right now.
Another solution would be to "open" C-based classes to allow modification, that is not planned to be into near future Python versions AFAIK.
I came to fill a new bug with all this, but then found this one that is already mature enough, with even BDFL and python-dev opinion.
Then my (maybe pointless) plan was to gather more arguments favor to change into python-based datetime, but you replied first...
Alan Justino wrote:
It's usually better to use a central helper get_current_time() in