Message209153
(I already sent this to python-dev, but maybe it makes more sense to have these thoughts together with the patch)
After looking at the conversion of parse_time_t_args again, I think I lost track of what we're actually gaining with this procedure. If all we need is a type that can distinguish between a valid time_t value and a default value, why don't we simply use PyObject?
In other words, what's the advantage of the extra custom strict, plus the custom C converter function, plus the custom converter python class over:
static int
PyObject_to_time_t(PyObject *obj, time_t *when)
{
if (obj == NULL || obj == Py_None)
*when = time(NULL);
else if (_PyTime_ObjectToTime_t(obj, when) == -1)
return 0;
return 1;
}
/*[clinic input]
time.gmtime
seconds: object=NULL
/
[...]
static PyObject *
time_gmtime_impl(PyModuleDef *module, PyObject *seconds)
{
PyObject *return_value = NULL;
time_t when;
if(!PyObj_to_time_t(seconds, &when))
return NULL;
[...]
To me this version looks shorter and clearer. |
|
Date |
User |
Action |
Args |
2014-01-25 06:07:20 | nikratio | set | recipients:
+ nikratio, larry, skrah |
2014-01-25 06:07:20 | nikratio | set | messageid: <1390630040.59.0.00516212719455.issue20177@psf.upfronthosting.co.za> |
2014-01-25 06:07:20 | nikratio | link | issue20177 messages |
2014-01-25 06:07:19 | nikratio | create | |
|