What about creating a cache of pre-loaded methods from the ndarray type?

As long as these methods are the tiny objects wrapping the PyCFunction
pointer, the only overhead you will have is :

1- Cython creating a tuple to call the FUNC(args) # Cython sees FUNC
as a normal func.

2- Python enters tp_call slot in the method type, and then does some
stuff in C to split args in two:  self<-args[0] and
otherargs<-args[1:], plus dispatching the final C call cfunc(self,
otherargs) taking into accout some flags...

4- NumPy (C) code doing tuple arg unpacking...

But all the above steps are in C, and you save the dict lookup...

A more cute implementation could even skip step (2) by catching the
PyCFunction pointer and some flags from the PyMethodDef struct...
Though I doubt we could gain too much...

Of course, I'm just throwing wild ideas.... Never tried to subclass
numpy, though I'm pretty sure we could found a way to solve the
__new__ problem (in the case we actually need to solve something)

And of course, all this would perhaps require some script generating
(Cython) code, and perhaps some pure-C utility code...



On Fri, Mar 20, 2009 at 11:56 PM, Brian Granger <[email protected]> wrote:
>> What do you mean for fast methods calls? Skipping the lookup in the
>> type's dict? In such case, I can imagine some easy and some not so
>> easy (though a bit faster) ways of doing this
>
> In certain cases, I would love to be able to avoid this overhead.
> What ideas do you have in mind?
>
> Brian
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to