Stefan Behnel wrote:
> Hi,
>
> Robert Bradshaw wrote:
>   
>> On Aug 23, 2008, at 9:00 AM, Stefan Behnel wrote:
>>     
>>> The only case where we are still a bit slower than Python is when you
>>> pass (almost) all arguments as keyword arguments. [...] However, as the
>>> absolute numbers compared to Python show, this may not be worth the
>>> effort.
>>>       
>> Maybe. It wouldn't be a huge savings nor a common case, and there is the
>> issue of bloating the header of the function, so I think what you have is
>> great.
>>     
>
> I agree even more now that I did a little more tweaking for kw unpacking,
> especially for the case where **kwargs and/or *args are used. It's another bit
> faster in total (mainly by generating more optimistic code) and we use less
> helper functions (which are really only called when necessary). There's also a
> pretty good split of the error handling between the generic helpers and the
> generated in-place code now.
Thanks again for doing this.

Does anyone have any thoughts about the external typedef issue with 
argument unpacking? I see that with Stefan's code we get an exception 
rather than a segfault which is a big step forward, but one could still 
think a bit about what the behaviour should be (i.e. if people wants to 
use numpy.uint16_t as a function argument type I want a defined 
behaviour for that.)

Example:

test.h:
typedef long int my_int;

test.pyx:

cdef extern from "test.h":
    ctypedef char myint

def myfunc(myint x):
    pass

Now, myfunc(1000) will raise an overflow exception.

Granted, this is an extreme example. I just want a defined behaviour on 
this somehow, and documenting the existing one could be ok. If we want 
to support it without assumptions on the size, something like

#define __Pyx_FetchPyInt(result, from) switch(sizeof(result)) {\
  case sizeof(char): result = __pyx_PyInt_char(from); break;
  case sizeof(int):
  ....
   default: __Pyx_RaiseFetchPyIntError(from); result = -1;
}

should do the trick (and it is only needed when the typedef is extern). 
Will a patch like that be accepted? (It will have to wait a month or two 
if I'm the one doing it, but I am not expecting anybody else to in the 
meantime.)

Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to