Pauli Virtanen, 08.03.2014 21:11: > FYI: Cython instantiates fused type routines with memoryview arguments > unnecessarily many times. > > Example: > ``` > ctypedef fused idx_t: > short > long > > # Cython 0.20.1 instantiates this function 128 times, > # even though only 2 would be needed > def fubar_128(idx_t[:] a, > idx_t[:] b, > idx_t[:] c, > idx_t[:] d, > idx_t[:] e, > idx_t[:] f, > idx_t[:] g): > print("HALLO") > > def fubar_2(idx_t a, > idx_t b, > idx_t c, > idx_t d, > idx_t e, > idx_t f, > idx_t g): > print("HULLO") > ``` > $ cython cymod.pyx > $ cython --version > Cython version 0.20.1 > $ grep -c 'print("HALLO")' cymod.c > 128 > $ grep -c 'print("HULLO")' _cymod.c > 2 > > The n**m explosion starts to hurt quite quickly when there are several > array arguments and more than one fused type. I think this issue is > also accompanied by some signature resolution bugs (I'll try to come > up with an example case).
Yes, this is a known problem. The work-around is to ctypedef the memory view type, not just the dtype. http://thread.gmane.org/gmane.comp.python.cython.user/10437 Stefan _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel