Alex S. schrieb am 15.07.2015 um 13:51:
> The issue was described here: http://trac.cython.org/ticket/847 but was,
> however, misidentified. The wrapper for a function which receives "fused
> slice" (D[:]) arguments automatically includes the following code:
>>                 cdef type ndarray
>>                 try:
>>                     import numpy
>>                     ndarray = numpy.ndarray
>>                 except (ImportError, AttributeError, TypeError):
>>                     ndarray = None
> (Compiler/FusedNode.py:468).
> When numpy is not installed, each import tries to search for it in the
> system path. (When it is, it's just cached). This severely degrades the
> performance.

Sounds like enabling the absolute_import future import might help at least
a little.

https://github.com/cython/cython/commit/ac4f248b4109cb17b2da53dc7b38e359c5dee612

But yes, this is definitely a problem. In general, the way extension types
are handled in the fused types dispatch code (and that includes numpy
arrays) would seriously benefit from optimisation, including cached
one-time imports.

Stefan

_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to