22.01.14 07:13, Nikolaus Rath написав(ла):
To me this version looks shorter and clearer. Is there really an
advantage in defining the clinic argument as a custom struct rather than
object?
To me too.
___
Python-Dev mailing list
Python-Dev@python.org
Larry Hastings writes:
> All is not lost! What follows is rough pseudo-C code, hopefully you
> can take it from here.
>
>typedef struct {
> int set;
> time_t when;
>} clinic_time_t;
>
>#define DEFAULT_CLINIC_TIME_T {0, 0}
>
>static int
>parse_clinic_time_t_arg(PyOb
Yes, I meant in the definition of the convertor class. You can fix c_default
in converter_init.
On Jan 21, 2014 7:19 PM, Nikolaus Rath wrote:
>
> Larry Hastings writes:
> > A comment on your approach so far: I'm very much against giving
> > "default" a default value in the constructor.
>
> You
Larry Hastings writes:
> A comment on your approach so far: I'm very much against giving
> "default" a default value in the constructor.
You mean in the definition of the custom converter class?
> I realize that hack saves you having to say "= NULL" in a lot of
> places. But explicit is better
On 01/21/2014 12:59 AM, Serhiy Storchaka wrote:
21.01.14 04:44, Nikolaus Rath написав(ла):
Serhiy Storchaka writes:
20.01.14 06:19, Nikolaus Rath написав(ла):
This works if the user calls time.gmtime(None), but it fails for
time.gmtime(). It seems that in that case my C converter function is
21.01.14 04:44, Nikolaus Rath написав(ла):
Serhiy Storchaka writes:
20.01.14 06:19, Nikolaus Rath написав(ла):
This works if the user calls time.gmtime(None), but it fails for
time.gmtime(). It seems that in that case my C converter function is
never called.
What's the trick that I'm missing?
On 01/20/2014 06:44 PM, Nikolaus Rath wrote:
All in all, I'm still not sure how I'm supposed to proceed. I see the
following options (and I'm fine with all of them):
1. Use the option group with a custom converter. This means a time(NULL)
call even if the caller passed a parameter.
2. Decla
Serhiy Storchaka writes:
> 20.01.14 06:19, Nikolaus Rath написав(ла):
>> This works if the user calls time.gmtime(None), but it fails for
>> time.gmtime(). It seems that in that case my C converter function is
>> never called.
>>
>> What's the trick that I'm missing?
>
> /*[clinic input]
> time.gm
Ryan Smith-Roberts writes:
> The trick you're missing is that *any time* you have an optional argument
> with a custom converter[1], PyArg_ParseTuple *only* calls the converter
> function in the case that the user *actually supplies some value*. This is
> a basic property of an optional argument.
The trick you're missing is that *any time* you have an optional argument
with a custom converter[1], PyArg_ParseTuple *only* calls the converter
function in the case that the user *actually supplies some value*. This is
a basic property of an optional argument. Another property is that the
c_defau
20.01.14 06:19, Nikolaus Rath написав(ла):
This works if the user calls time.gmtime(None), but it fails for
time.gmtime(). It seems that in that case my C converter function is
never called.
What's the trick that I'm missing?
/*[clinic input]
time.gmtime
[
seconds: time_t
]
/
Larry Hastings writes:
> On 01/18/2014 09:52 PM, Ryan Smith-Roberts wrote:
>>
>> I still advise you not to use this solution. time() is a system call
>> on many operating systems, and so it can be a heavier operation than
>> you'd think. Best to avoid it unless it's needed (on FreeBSD it
>> seems
Larry Hastings writes:
> On 01/18/2014 09:52 PM, Ryan Smith-Roberts wrote:
>>
>> I still advise you not to use this solution. time() is a system call
>> on many operating systems, and so it can be a heavier operation than
>> you'd think. Best to avoid it unless it's needed (on FreeBSD it
>> seems
On Sun, Jan 19, 2014 at 2:38 AM, Larry Hastings wrote:
> According to the issue tracker, " rmsr" has only ever filed one issue.
> I just fixed (and closed) it.
>
The two issues were "custom converter with converter and default raises
exception" and "custom converter with py_default and c_defaul
On 01/18/2014 09:52 PM, Ryan Smith-Roberts wrote:
I still advise you not to use this solution. time() is a system call
on many operating systems, and so it can be a heavier operation than
you'd think. Best to avoid it unless it's needed (on FreeBSD it seems
to add about 15% overhead to local
Ah yes, my apologies, I was thrown off by the first converter declaration
in your class and didn't spot the second, so didn't realize what you were
up to.
I still advise you not to use this solution. time() is a system call on
many operating systems, and so it can be a heavier operation than you'd
Hi Ryan,
Ryan Smith-Roberts writes:
> Hi Nikolaus. I also started a conversion of timemodule, but dropped it when
> I saw in the issue that you had taken over that conversion. I also tried to
> turn parse_time_t_args into a converter. However, it won't work. The
> problem is that parse_time_t_ar
Hi Nikolaus. I also started a conversion of timemodule, but dropped it when
I saw in the issue that you had taken over that conversion. I also tried to
turn parse_time_t_args into a converter. However, it won't work. The
problem is that parse_time_t_args must be called whether or not the user
suppl
Hello,
I'm trying to convert functions using parse_time_t_args() (from
timemodule.c) for argument parsing to argument clinic.
The function is defined as:
,
| static int
| parse_time_t_args(PyObject *args, char *format, time_t *pwhen)
| {
| PyObject *ot = NULL;
| time_t whent;
|
|
19 matches
Mail list logo