On Fri, May 23, 2008 at 10:36 AM, Dag Sverre Seljebotn
<[EMAIL PROTECTED]> wrote:
> Carl Witty wrote:
>>
>> I was hoping this would be powerful enough to write generic optimized
>> mathematics code for Sage, but it doesn't do enough for that.
>
> Let me hear your opinion on this though.
>
> If this is implemented, one could move on to compile-time optimize away
> isinstance in a few trivial cases. I.e you could do:
>
> cdef generic gen_add(generic b, generic c):
> if isinstance(b, mpz_t):
> ...
> elif isinstance(b, ...
>
> This would be a later addition, but a natural one and one that I would
> like to have for NumPy (regardless on whether overloading on the argument
> types is introduced as well). Would this solve your case?
Perhaps. What does "cdef generic gen_add" mean? (How does it figure
out what the return type really is?)
It would have to somehow split into two cases, between reference types
and value types:
if gen_is_reference(b):
gen_ref_add(a, b, c)
else:
a = gen_add(b, c)
Carl
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev