[issue9079] Make gettimeofday available in time module

2012-03-13 Thread STINNER Victor
STINNER Victor added the comment: > The new patch, issue9079.diff exposes gettimeofday > as time.gettimeofday() returning (sec, usec) pair. A tuple is not the preferred type for a timestamp: Python uses float and is not going to use something different (the PEP 410 was just rejected). I don't

[issue9079] Make gettimeofday available in time module

2010-10-05 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +haypo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue9079] Make gettimeofday available in time module

2010-08-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Committed issue9079c.diff as r83744. This commit does not provide time.gettimeofday() and therefore does not close the issue. -- keywords: -needs review, patch stage: commit review -> needs patch ___ Python

[issue9079] Make gettimeofday available in time module

2010-08-05 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Updated the patch to reflect recent datetimemodule.c renaming to _datetimemodule.c. No other changes between issue9079b.diff and issue9079c.diff. I am going to commit issue9079c.diff soon unless someone wants more time to review. -- Added fi

[issue9079] Make gettimeofday available in time module

2010-07-21 Thread Brian Curtin
Brian Curtin added the comment: I won't have time to review this, but I can say issue9079b.diff works fine on Windows. -- ___ Python tracker ___

[issue9079] Make gettimeofday available in time module

2010-07-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: issue9079b.diff should fix the Windows issue. -- Added file: http://bugs.python.org/file18108/issue9079b.diff ___ Python tracker ___ _

[issue9079] Make gettimeofday available in time module

2010-07-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I think Reid nailed the issue. Fix is coming. -- ___ Python tracker ___ ___ Python-bugs-list

[issue9079] Make gettimeofday available in time module

2010-07-21 Thread Brian Curtin
Brian Curtin added the comment: Here are the errors I get: Error 104 error C2037: left of 'tv_sec' specifies undefined struct/union 'timeval'c:\python-dev\py3k\Python\pytime.c 46 pythoncore Error 105 error C2037: left of 'tv_usec' specifies undefined struct/union 'tim

[issue9079] Make gettimeofday available in time module

2010-07-21 Thread Reid Kleckner
Reid Kleckner added the comment: I think you used 'struct timeval *' in the function definition instead of '_PyTimeVal *'. -- ___ Python tracker ___

[issue9079] Make gettimeofday available in time module

2010-07-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Interesting. As far as I can tell, struct timeval should not be used unless HAVE_GETTIMEOFDAY is defined: +#ifdef HAVE_GETTIMEOFDAY +typedef struct timeval _PyTime_timeval; +#else +typedef struct { +time_t tv_sec; /* seconds since Jan. 1, 19

[issue9079] Make gettimeofday available in time module

2010-07-21 Thread Brian Curtin
Brian Curtin added the comment: issue9079a.diff doesn't compile on Windows - timeval isn't defined. You'd have to include Winsock2.h [0]. Adding something like the following within the HAVE_FTIME block would work... #ifdef MS_WINDOWS #include #endif I don't currently have time to dig deeper

[issue9079] Make gettimeofday available in time module

2010-07-21 Thread Reid Kleckner
Reid Kleckner added the comment: pytime.h looks like it got pasted into the file twice. Other than that, it looks good to me and the tests pass on OS X here. -- ___ Python tracker

[issue9079] Make gettimeofday available in time module

2010-07-17 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file18034/issue9079a.diff ___ Python tracker ___ ___ Python-bugs-list ma

[issue9079] Make gettimeofday available in time module

2010-07-17 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Indeed. Replacing issue9079a.diff now. -- Added file: http://bugs.python.org/file18045/issue9079a.diff ___ Python tracker ___ ___

[issue9079] Make gettimeofday available in time module

2010-07-17 Thread Reid Kleckner
Reid Kleckner added the comment: I think you forgot to svn add pytime.c before making the diff. -- ___ Python tracker ___ ___ Python-b

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It turns out I misunderstood how date.today() worked [1] and issue9079.diff introduced significant change in behavior. Bringing timeofday into core rather than _time.c also introduced several complications. As a result it makes sense to start with jus

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Reid Kleckner
Reid Kleckner added the comment: I'd really rather not try to rely module loading from a threading primitive. :) I think if you follow Antoine's suggestion of adding _PyTime_Init (which does nothing in the body other than a comment) it should work fine. -- __

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Reid, I am leaning towards reverting to Plan A (issue9079.diff). Would your use case be served well by a _time module exposing C API via a capsule? This what datetime does currently. -- ___ Python tracker

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Jeff Yasskin says you should create a noop function in your object > file and call it from PyMain for force linkage of the object file > you're building. Indeed, something like _PyTime_Init(). I don't think Modules/python.c is a good place though, since it me

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Reid Kleckner
Reid Kleckner added the comment: Right, it's one of the peculiarities of archive files (I think). When none of an object file's symbols are used from the main program, the object file is dropped on the floor, ie not included. This has bizarre consequences in C++ with static initializers, wh

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Mark Dickinson
Mark Dickinson added the comment: > Hmm, after thinking about it, what happens is that the C object file is > not used at all, so it's probably optimized away by the linker. That sounds right. I recall similar problems with pymath.c at one stage: none of the functions it defined was being us

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: > > It looks like my reluctance to add gettimeofday to core without using > > it there was well founded. Simply adding a dummy call to > > _PyTime_gettimeofday in main() fixed the build problem. > > It's rather strange. I'm sure we have external API functions

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: > It looks like my reluctance to add gettimeofday to core without using > it there was well founded. Simply adding a dummy call to > _PyTime_gettimeofday in main() fixed the build problem. It's rather strange. I'm sure we have external API functions which neve

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It looks like my reluctance to add gettimeofday to core without using it there was well founded. Simply adding a dummy call to _PyTime_gettimeofday in main() fixed the build problem. This is a hack, of course, so I am still looking for suggestions on

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file18031/issue9079-fail.diff ___ Python tracker ___ ___ Python-bugs-lis

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Removing spurious configure change from the "fail" patch. -- Added file: http://bugs.python.org/file18032/issue9079-fail.diff ___ Python tracker _

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file18030/issue9079-fail.diff ___ Python tracker ___ ___ Python-bugs-lis

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I fixed the ftime issue (I hope), but the build still fails. I did not test on Linux, but I tested on OSX with HAVE_FTIME. Replacing the failing patch. -- Added file: http://bugs.python.org/file18031/issue9079-fail.diff ___

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Georg Brandl
Georg Brandl added the comment: I'd like to help diagnose but I don't know what "Erreur 1" means. -- nosy: +georg.brandl ___ Python tracker ___ __

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Antoine, you must be building on Windows. I'll try to guess where ftime is defined and repost the patch. -- ___ Python tracker ___

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le vendredi 16 juillet 2010 à 19:51 +, Alexander Belopolsky a écrit : > Alexander Belopolsky added the comment: > > No it must be something else. Attached issue9079-fail.diff fails with Here it fails earlier: gcc -pthread -c -DNDEBUG -g -fwrapv -O3 -Wa

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Added file: http://bugs.python.org/file18030/issue9079-fail.diff ___ Python tracker ___ ___ Python-bugs-list

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: No it must be something else. Attached issue9079-fail.diff fails with Symbol not found: __PyTime_gettimeofday Referenced from: .../build/lib.macosx-10.4-x86_64-3.2-pydebug/datetime.so even though it is in pytime.o $ nm ./Python/pytime.o 000

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Antoine Pitrou
Antoine Pitrou added the comment: > OK, can someone show me an example of how functions defined in core > Python can be made available to extension modules? I thought I could > model pytime.h/.c after pymath.h/.c, but the later is not used in > extension modules. I must be missing something tr

[issue9079] Make gettimeofday available in time module

2010-07-16 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: OK, can someone show me an example of how functions defined in core Python can be made available to extension modules? I thought I could model pytime.h/.c after pymath.h/.c, but the later is not used in extension modules. I must be missing something t

[issue9079] Make gettimeofday available in time module

2010-07-14 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: +tim.golden ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://ma

[issue9079] Make gettimeofday available in time module

2010-07-12 Thread Reid Kleckner
Reid Kleckner added the comment: The patch looks good to me FWIW. I would be interested in using this perhaps in issue8844, which involves lock timeouts. It may be true that the POSIX API uses nanoseconds, but pythreads only exposes microsecond precision. In order to use it from the thread

[issue9079] Make gettimeofday available in time module

2010-07-12 Thread Mark Dickinson
Changes by Mark Dickinson : -- assignee: mark.dickinson -> belopolsky ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue9079] Make gettimeofday available in time module

2010-07-12 Thread Mark Dickinson
Mark Dickinson added the comment: Assigning back to Alexander; sorry I haven't had time to look at this. -- ___ Python tracker ___ __

[issue9079] Make gettimeofday available in time module

2010-07-12 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Mon, Jul 12, 2010 at 1:06 PM, Antoine Pitrou wrote: .. > Indeed, the GIL code would probably still use its own code paths. > However, other less sensitive code could rely on the new API. For > example, it is not critical for lock timeouts to benefit fr

[issue9079] Make gettimeofday available in time module

2010-07-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: > > Instead of being defined in _time.h, perhaps the new API function should be > > provided by core Python? > > This is an interesting idea, but proposed Py_gettimeofday inherits > float_time logic of falling back on ftime and then plain time in case > gettim

[issue9079] Make gettimeofday available in time module

2010-07-12 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Mon, Jul 12, 2010 at 12:07 PM, Antoine Pitrou wrote: .. > Instead of being defined in _time.h, perhaps the new API function should be > provided by core Python? This is an interesting idea, but proposed Py_gettimeofday inherits float_time logic of fa

[issue9079] Make gettimeofday available in time module

2010-07-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Instead of being defined in _time.h, perhaps the new API function should be provided by core Python? It would probably help in certain threading primitives. -- nosy: +pitrou ___ Python tracker

[issue9079] Make gettimeofday available in time module

2010-06-29 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The original patch, gettimeofday.diff was just refactoring. I unlinked it to keep the file list clean, but it is still available: http://bugs.python.org/file17766/gettimeofday.diff I decided to expose time.gettimeofday() in the same patch mostly in ord

[issue9079] Make gettimeofday available in time module

2010-06-29 Thread Mark Dickinson
Mark Dickinson added the comment: To keep things clean, would it be possible to separate this into two patches, one containing the refactoring and one for the newly exposed gettimeofday? -- ___ Python tracker

[issue9079] Make gettimeofday available in time module

2010-06-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I would very much appreciate Tim's input on datetime issues. This particular issue is fairly minor, but Tim's expertise will be invaluable for anything timezone related. I do appreciate the incredible amount of brainpower that went into the design of

[issue9079] Make gettimeofday available in time module

2010-06-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: It would be great if Tim Peters could be consulted about some of these ideas. He put a great deal of thought into the API, what should be included and what should be excluded. -- nosy: +rhettinger ___ Python tr

[issue9079] Make gettimeofday available in time module

2010-06-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Mark, I am reassigning this to you for commit review. I am changing the title to reflect the visible part of the change. The datetime module gains direct access to system gettimeofday at the C level while time module grows time.gettimeofday() Python