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

2010-07-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Committed in r83112. -- resolution: accepted -> fixed stage: commit review -> committed/rejected status: open -> closed ___ Python tracker ___

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

2010-07-23 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Brian, thanks for the fix and for testing. I am attaching a commit-ready patch issue7989e.diff, that includes Brian's fix and a few white-space changes. I hope I've resolved the SVN issue: I was working in a read-only checkout while sandbox checkout w

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

2010-07-23 Thread Brian Curtin
Brian Curtin added the comment: One additional change was needed to compile on Windows: Index: PC/config.c === --- PC/config.c (revision 83087) +++ PC/config.c (working copy) @@ -116,7 +116,7 @@ {"parser", PyInit_parser},

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

2010-07-23 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file18148/datetimetester.py ___ Python tracker ___ ___ Python-bugs-list ma

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

2010-07-22 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17913/issue9206a.diff ___ Python tracker ___ ___ Python-bugs-list ma

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

2010-07-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: s/strictly necessary/not strictly necessary/ -- ___ Python tracker ___ ___ Python-bugs-list ma

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

2010-07-22 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > [datetime.c] needs to be renamed in Modules/Setup.dist, and most > importantly in PC/config.c Fixed in issue7989d.diff, thanks. In order to commit this patch I need an SVN advise. I would like to copy datetime.py from sandbox to py3k in a way that wi

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

2010-07-21 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: Technically, since the C module is now named _datetime, it needs to be renamed in Modules/Setup.dist, and most importantly in PC/config.c (because on Windows datetime is built in the main interpreter) -- ___

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

2010-07-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Is anyone interested in giving this a final review? I would like to check this in unless someone objects or needs time to review. -- ___ Python tracker

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

2010-07-21 Thread David Fraser
Changes by David Fraser : -- nosy: +davidfraser ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyth

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

2010-07-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: In issue7989c.diff, I reverted to lazy import of _strptime, added cleanup of _xyz helper functions, and made test_datetime more robust by restoring sys.modules more thoroughly. Unfortunately I've encountered an issue with Rietveld that prevents me from

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

2010-07-13 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +merwok ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org

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

2010-07-12 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file17978/issue9206b.diff ___ Python tracker ___ ___ Python-bugs-list mail

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

2010-07-12 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17976/issue9206b.diff ___ Python tracker ___ ___ Python-bugs-list ma

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

2010-07-12 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file17977/issue9206b.diff ___ Python tracker ___ ___ Python-bugs-list ma

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

2010-07-12 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file17977/issue9206b.diff ___ Python tracker ___ ___ Python-bugs-list mail

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

2010-07-12 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: issue9206b.diff fixes test_datetime in issue9206a.diff by restoring sys.modules in-place in tearDown method. Based on python-dev discussion, I am marking this as accepted and uploading the patch to Rietveld for commit review. Please comment on the code

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

2010-07-08 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: issue7989a.diff is a partial success implementing Nick Coghlan's testing idea. Unfortunately, datetime implementation with it's circular dependency on _strftime is not very robust with respect to import trickery. I am calling this a partial success bec

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

2010-07-04 Thread Tim Peters
Tim Peters added the comment: > ... > Another is tzinfo attribute of time. With time t, > t.utcoffset() is kid of useless given that you > cannot subtract it from t Sure you can - but you have to write your code to do time arithmetic. The time implementation does so under the covers when two

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

2010-07-03 Thread Giampaolo Rodola'
Changes by Giampaolo Rodola' : -- nosy: +giampaolo.rodola ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:/

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

2010-07-02 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- stage: needs patch -> patch review Added file: http://bugs.python.org/file17848/issue7989.diff ___ Python tracker ___

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching a patch from issue 5288 as an example of a change that I would favor more than issue7989-cmp.diff. This patch eliminates _utcoffset and _dst methods that duplicate utcoffset and dst, but return integer minutes rather than a timedelta. I

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Fri, Jul 2, 2010 at 6:52 PM, Marc-Andre Lemburg wrote: .. > That said, I don't think redesigning the datetime module is part > of this ticket, just adding a second implementation of what we > already have in CPython :-) I agree. I am just looking for

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

2010-07-02 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > > On Fri, Jul 2, 2010 at 6:00 PM, Tim Peters wrote: >> >> Tim Peters added the comment: >> >>> Do you remember why it was a good idea to >>> derive datetime from date? >> >> Why n

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Fri, Jul 2, 2010 at 6:26 PM, Tim Peters wrote: .. > I'm not going to argue about whether datetime "should have been" subclassed > from date - fact is that it was, and since it was > Guido's idea from the start, he wouldn't change it now even if his ti

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

2010-07-02 Thread Tim Peters
Tim Peters added the comment: I'm not going to argue about whether datetime "should have been" subclassed from date - fact is that it was, and since it was Guido's idea from the start, he wouldn't change it now even if his time machine weren't out for repairs ;-) -- _

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Fri, Jul 2, 2010 at 6:00 PM, Tim Peters wrote: > > Tim Peters added the comment: > >> Do you remember why it was a good idea to >> derive datetime from date? > > Why not?  A datetime is a date, but with additional behavior.  Makes > inheritance conce

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

2010-07-02 Thread Tim Peters
Tim Peters added the comment: > Do you remember why it was a good idea to > derive datetime from date? Why not? A datetime is a date, but with additional behavior. Makes inheritance conceptually natural. -- ___ Python tracker

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

2010-07-02 Thread Tim Peters
Changes by Tim Peters : -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/option

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

2010-07-02 Thread Tim Peters
Tim Peters added the comment: > I thought x was coming from integer > arithmetics, but apparently datetime.py loves floats! The arguments to __new__ can be floats, so it's necessary to deal with floats there. -- ___ Python tracker

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

2010-07-02 Thread Tim Peters
Tim Peters added the comment: > I thought x was coming from integer > arithmetics, but apparently datetime.py loves floats! The arguments to __new__ can be floats, so it's necessary to deal with floats there. -- ___ Python tracker

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Fri, Jul 2, 2010 at 5:23 PM, Amaury Forgeot d'Arc wrote: .. > Even with 2.5 int(x) cannot overflow, and returns a long when needed! > This assert probably checks that the number has no fractional part. Yes I've realized that. I thought x was coming f

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: This comment in datetime.__new__ makes me +0.5 on s/__/_/: self = date.__new__(cls, year, month, day) # XXX This duplicates __year, __month, __day for convenience :-(

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

2010-07-02 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: > assert daysecondswhole == int(daysecondswhole) # can't overflow > Since int is long in 3.x, this assert does not check anything Even with 2.5 int(x) cannot overflow, and returns a long when needed! This assert probably checks that the number has no

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > If they abuse the _ methods and complain that the C version doesn't > work, we just say "we *told* you not to do that". It is not the Python > philosophy to try to protect users from mistakes that they willfully > make. OK. +0 from me. Patches welcome

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > I am talking specifically about this kind of assert: > >assert 1 <= month <= 12, 'month must be in 1..12' > > I think it should be replaced with: > >if month < 1 or month > 12: >raise ValueError('month must be in 1..12') I reviewed the

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

2010-07-02 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > - I find the _cmp() and __cmp() indirection poor style in 3.x, > especially when you simply end up comparing self._getstate() and > other._getstate() (it is also suboptimal because it can do more > comparisons than needed) The best I could come up with

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

2010-07-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I agree. Do you think I should just define __lt__ and use > functools.total_ordering decorator? I had forgotten about functools.total_ordering. Yes, very good idea. > Note that current implementation mimics what is done in C, but I > think python should d

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

2010-07-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > R. David Murray added the comment: > > If they abuse the _ methods and complain that the C version doesn't > work, we just say "we *told* you not to do that".  It is not the Python > philosophy to try to protect users from mistakes that they willfully >

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

2010-07-01 Thread R. David Murray
R. David Murray added the comment: If they abuse the _ methods and complain that the C version doesn't work, we just say "we *told* you not to do that". It is not the Python philosophy to try to protect users from mistakes that they wilfully make. --

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

2010-07-01 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Thanks a lot for the review. Please see my replies below. On Thu, Jul 1, 2010 at 12:09 PM, Antoine Pitrou wrote: .. > - I find the _cmp() and __cmp() indirection poor style in 3.x, > especially when you simply end up comparing self._getstate() and > oth

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

2010-07-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: > In any case, my threshold for moving this forward is for someone to > review the code in sandbox. Ok some comments: - I find the _cmp() and __cmp() indirection poor style in 3.x, especially when you simply end up comparing self._getstate() and other._getsta

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

2010-06-26 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I see. I misunderstood AP's "although" as "however", but he probably meant "even though" or "in spite the fact that." Antoine, can I count you as "+1"? In any case, my threshold for moving this forward is for someone to review the code in sandbox. He

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

2010-06-26 Thread R. David Murray
R. David Murray added the comment: Alexander and Antoine, you are talking past each other. Alexander: Antoine was trying to point out that the fact that io is quirky has not impacted their ability to maintain parallel versions significantly. So if datetime is less quirky (and it probably is

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

2010-06-26 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le samedi 26 juin 2010 à 00:50 +, Alexander Belopolsky a écrit : > > For io, we find this quite manageable indeed, although it is quite more > > complex and quirkier than datetime. > > I don't understand how something being "more complex and quirkier," > ca

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

2010-06-26 Thread anatoly techtonik
anatoly techtonik added the comment: About importance to have a maintainable pure libraries and speedups for them. Believe it or not, but the only reason why Python 2.x did not get RFC 3339 implementation in standard library is that datetime module is in C. I hope everybody understands the im

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

2010-06-25 Thread Tim Peters
Tim Peters added the comment: > What would be your opinion on adding > datetime.py to the main python tree > today? The funny thing is I can't remember why we bothered creating the C version - I would have been happiest leaving it all in Python. Provided the test suite ensures the versions re

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

2010-06-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > For io, we find this quite manageable indeed, although it is quite more > complex and quirkier than datetime. I don't understand how something being "more complex and quirkier," can make it more "manageable." While admittedly simple, datetime has it's

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

2010-06-25 Thread Antoine Pitrou
Antoine Pitrou added the comment: > It is hard for me to judge the significance of maintenance burden, but > others reported that having parallel versions of the io module was > helpful. I believe that with proper support in the regression test > suit, it should be quite manageable. For io, we

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

2010-06-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Tim, thanks for your prompt reply. What would be your opinion on adding datetime.py to the main python tree today? There is momentum behind several features to be added to datetime module and having easily accessible prototype would give similar benefit

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

2010-06-25 Thread Tim Peters
Tim Peters added the comment: > It would be great if you could shed > some light on the history behind pure > python implementation. Why was it > developed in the first place? It was rapid prototyping - design decisions were changing daily, and it goes a lot faster to change Python code than

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

2010-06-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Adding tim_one to the nosy list. Tim, It would be great if you could shed some light on the history behind pure python implementation. Why was it developed in the first place? What was the reason not to ship it with python? Thanks. -- nosy:

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

2010-06-25 Thread R. David Murray
R. David Murray added the comment: Victor: that was exactly the point of my post that you partially quoted :) -- ___ Python tracker ___ __

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

2010-06-24 Thread STINNER Victor
STINNER Victor added the comment: Why do you need a pure Python version of datetime: - it's easier to work on a new feature first in Python: there are more people are able to write Python code, than people able to write C code (especially C code using the Python C API) - it helps datetime de

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

2010-06-19 Thread R. David Murray
R. David Murray added the comment: Brett's assertion comes from the decision made at the language summit at the last pycon. Which does not negate Raymond's assertion that there may be more important stuff to pythonize. However, Alexander is maintaining datetime, and if he wishes to do the Pyt

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

2010-06-18 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I was probably misled by Brett's assertion that 'it's not a matter of "if" but "when" datetime will get a pure Python version.' (msg106498) It looks like this is not a universally shared opinion. I am not ready to form a final opinion on datetime.py.

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

2010-06-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: > My understanding is that the desire to have pure > python versions of standard library modules is > to decouple the standard library from dependency > on CPython as far as practical. That is a bit of a broad brush. I do not know of an approved project

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

2010-06-18 Thread R. David Murray
R. David Murray added the comment: My understanding is that the desire to have pure python versions of standard library modules is to decouple the standard library from dependency on CPython as far as practical. Perhaps all existing Python implementations have dealt with datetime somehow, bu

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

2010-06-18 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Let me just add a story to show how an alternate python implementation may be useful for users. As I was porting datetime.py to 3.x, I saw many failures from pickle tests. It was not easy to figure out what was going on because C pickle code was calli

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

2010-06-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: I've been thinking about this feature request and am starting to question whether it is necessary. Usually we need a pure python version when 1) the python module is developed first, with the subsequent C code needing to match, or 2) we expect a porting i

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

2010-06-18 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: If both implementations can exist in the same interpreter, how will they cooperate? For example, Time instances created with datetime.py won't pass PyTime_Check(). -- ___ Python tracker

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

2010-06-18 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: >> One, we should not blindly pull in the PyPy code >> without some core PyPy developer being in on this You can count me among the PyPy developers. > I concur. Much of PyPy code is written for a restricted subset of > Python instead of clean, idiomatic

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

2010-06-17 Thread Brett Cannon
Brett Cannon added the comment: I would not worry about the history too much; the code has been forked and pulling it back in means there is already some history missing. Just do what is easiest. -- ___ Python tracker

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching datetime-sandbox-pypy.diff, a plain diff between six-year-old sandbox and pypy versions. (Plain diff is cleaner than unified diff.) You can see that the differences are trivial. I notice, however that original datetime implementation wa

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

2010-06-17 Thread Brett Cannon
Brett Cannon added the comment: I would simply email their developer mailing list (find it at http://pypy.org/contact.html) and say that you are willing to work on this. Maciej and I have discussed this before, so this won't be a total shock to them. As for Raymond's comment, I think he under

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: >> One, we should not blindly pull in the PyPy code >> without some core PyPy developer being in on this > > I concur.  Much of PyPy code is written for a restricted subset of > Python instead of clean, idiomatic modern Python. Raymond, I think you misrea

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > Also, this should not be marked as high priority. It may be a > personal priority for you, ... Reverting priority. I thought once an issue is assigned, the priority becomes the priority that assignee places on the issue. Sorry for the confusion. ---

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

2010-06-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: > One, we should not blindly pull in the PyPy code > without some core PyPy developer being in on this I concur. Much of PyPy code is written for a restricted subset of Python instead of clean, idiomatic modern Python. Also, this should not be marked as

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

2010-06-17 Thread Brett Cannon
Brett Cannon added the comment: A couple of things about all of this. One, we should not blindly pull in the PyPy code without some core PyPy developer being in on this; just common courtesy and I don't think anyone participating in this discussion is a PyPy developer (but I could be wrong).

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

2010-06-17 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

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

2010-06-17 Thread R. David Murray
R. David Murray added the comment: I don't see how "moving the import to setUp" is going to avoid having to explicitly run each set of tests twice, though. -- ___ Python tracker ___

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Porting PyPy implementation to 2.7 was fairly easy. I am posting the patch which makes PyPy datetime.py pass regression tests when dropped in the trunk. I expect 3.x port to be uneventful as well. Raising the priority because I would like to check thi

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > The only alternative is to manually duplicate tests, these leads to very > poor test coverage because of the average developer's laziness (json is > an example). No, here is another alternative: ==> _example.py <== def foo(): print(__name__) ==>

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

2010-06-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Alexander Belopolsky wrote: > > Alexander Belopolsky 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

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

2010-06-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I looked at test_io and don't like that approach. It seems to require > subclassing each TestCase twice for C and Python. There is no > mechanism to assure that all tests are replicated that way. Subclassing /is/ the mechanism :) Furthermore, some rare test

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Thu, Jun 17, 2010 at 10:32 AM, Antoine Pitrou wrote: .. >> Is there direct regrtest support for this? > > You can take a look at test_io, test_memoryio or test_heapq for inspiration. > I looked at test_io and don't like that approach. It seems to req

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

2010-06-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > > On Thu, Jun 17, 2010 at 10:31 AM, Marc-Andre Lemburg > wrote: > .. >> To avoid the wasted memory and import time, it's better to use: >> >> try: >>from _cmodule import * >>

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

2010-06-17 Thread R. David Murray
R. David Murray added the comment: I think we have no standard for this yet, though it has been discussed. If you can't find a python-dev thread about it, you should probably start a new one. As one example, heapq does: try: from _heapq import * except ImportError: pass aft

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky 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 go

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Thu, Jun 17, 2010 at 10:31 AM, Marc-Andre Lemburg wrote: .. > To avoid the wasted memory and import time, it's better to use: > > try: >    from _cmodule import * > except ImportError: >    from _pymodule import * > Hmm, I cannot find the relevant th

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

2010-06-17 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Is this still the state of the art? What about parsing overhead? The io module has three modules: - io.py just imports everything from _io - _io is the default C implementation - _pyio.py must be imported explicitly to get the pure Python implementation =>

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

2010-06-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Alexander Belopolsky wrote: > > Alexander Belopolsky added the comment: > > I would like to move this forward. The PyPy implementation at > > http://codespeak.net/pypy/dist/pypy/lib/datetime.py > > claims to be based on the original CPython datetime im

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

2010-06-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I would like to move this forward. The PyPy implementation at http://codespeak.net/pypy/dist/pypy/lib/datetime.py claims to be based on the original CPython datetime implementation from the time when datetime was a python module. I looked through the

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

2010-06-10 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: STINNER Victor wrote: > > STINNER Victor added the comment: > > I like the idea of a pure Python implementation of the datetime module, for > different reasons: > - it will become the reference implementation > - other Python interpreters can use it >

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

2010-06-10 Thread STINNER Victor
STINNER Victor added the comment: I like the idea of a pure Python implementation of the datetime module, for different reasons: - it will become the reference implementation - other Python interpreters can use it - it can be used to test another implementation, eg. the current C version -

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

2010-06-10 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Brett Cannon wrote: > > Brett Cannon added the comment: > > So yes, cPickle/pickle, cStringIO/StringIO, heapq, etc. are all examples of > the approach. One could choose to write the pure Python version first, > profile the code, and only write extension

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

2010-06-08 Thread Brett Cannon
Brett Cannon added the comment: So yes, cPickle/pickle, cStringIO/StringIO, heapq, etc. are all examples of the approach. One could choose to write the pure Python version first, profile the code, and only write extension code for the hot spots, but obviously that typically doesn't happen. A

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

2010-06-08 Thread anatoly techtonik
anatoly techtonik added the comment: On Tue, Jun 8, 2010 at 2:06 PM, Amaury Forgeot d'Arc wrote: > > Even from pypy perspective, a pure python implementation is not ideal because > it makes it difficult to implement the C API. C API must die a shadow of Go -- ___

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

2010-06-08 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: Even from pypy perspective, a pure python implementation is not ideal because it makes it difficult to implement the C API. -- nosy: +amaury.forgeotdarc ___ Python tracker _

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

2010-06-08 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Oops, sorry. Looks like the Roundup email interface changed the ticket title back to the old one again (I was replying to Brett's comment under the old title). -- title: Transition time/datetime C modules to Python -> Add pure Python implementatio

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

2010-06-07 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am changing the title to match Brett's explanation better. Note that since the time module is a thin wrapper around C library calls, it falls under inherently relying on C code exception. -- title: Transition time/datetime C modules to Python