[Patches] [Patch #103265] Let time functions default to 'now' (where it makes sense)

noreply@sourceforge.net noreply@sourceforge.net
Fri, 19 Jan 2001 15:18:54 -0800


Patch #103265 has been updated. 

Project: python
Category: Modules
Status: Closed
Submitted by: twouters
Assigned to : twouters
Summary: Let time functions default to 'now' (where it makes sense)

Follow-Ups:

Date: 2001-Jan-19 15:18
By: twouters

Comment:
Checked in, revision 2.105 of Modules/timemodule.c, 1.35 of
Doc/lib/libtime.tex and 1.102 of Misc/NEWS.

-------------------------------------------------------

Date: 2001-Jan-19 14:53
By: fdrake

Comment:
The docs look good -- please include them in the checkin.
-------------------------------------------------------

Date: 2001-Jan-19 14:48
By: gvanrossum

Comment:
Thomas, please check this in -- there's still time to get it into 2.1a1. 
Then reassign to Fred for the docs!
-------------------------------------------------------

Date: 2001-Jan-17 07:50
By: gvanrossum

Comment:
Thomas, go for it.  I'd say "the current time" instead of "now" in the NEWS
item.  I'll defer to Fred for the docs.

-------------------------------------------------------

Date: 2001-Jan-17 06:55
By: twouters

Comment:
That's what I meant with 'check the size', but I still think it kind of
breaks the abstraction of 'args'. Not in a terribly scary way, but the
difference between calling floattime() always and doing a check whether or
not to call floattime() isn't that big either.

But you is BDFL, boss, so here's a patch that does it your way :) It also
adds a NEWS entry and fixes the docs for timemodule (including docstrings.)
Assigned to Fred so he can take a quick look at the docs. Don't need to
check the TeX code though, Fred, I successfully built ps files on my laptop
:)



-------------------------------------------------------

Date: 2001-Jan-17 06:01
By: gvanrossum

Comment:
With METH_VARARGS, args is guaranteed to be a tuple, so you can simply use
PyTuple_Size().

-------------------------------------------------------

Date: 2001-Jan-17 01:24
By: twouters

Comment:

Calling floattime() only when necessary would be nice, but isn't possible
without a value that reads as 'empty'. There is no way to see whether
optional values of a ParseTuple call were filled or not, except by
comparing the old value with the new one, and that means making a token
float value that means 'no argument'. We could check the length of 'args'
to see howmany arguments it contains, but that is a very fragile way, and
breaks the wonderful transparentness of argument-passing and
PyArg_Parse*.

The alternative to this approach is not reading a double from the arglist,
but a Python object (initialized as NULL,) and converting that to a float.
That would have my preference over the other two options, above, but I
still prefer the current way -- much less code, not that much slower (if
slower at all, I didn't time it.)

(Unless of course there is a way to see howmany optional arguments were
used ? Like a separate format character that fills an int with that
information, or a separate PyArg API call that returns not success/failure,
but the number of optional arguments used, and -1 on failure.)

I'll add news + docs, too,  sometime before friday if work permits :P

-------------------------------------------------------

Date: 2001-Jan-16 20:29
By: gvanrossum

Comment:
How hard would it be to avoid calling floattime() when an argument is
present (in gmtime() and localtime())?

Missing: docs, NEWS item.

Otherwise, great -- ready to check in if you fix the above things!


-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=103265&group_id=5470