[Cython] Fwd: [BUG] Cython failing performance when Numpy is not installed

Alex S. alex0player at gmail.com
Tue Jul 21 12:47:26 CEST 2015


2015-07-17 11:02 GMT+03:00 Stefan Behnel <stefan_ml at behnel.de>:

> 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
>
> Thank you for your response!
There's a similar problem in the Utility/MemoryView.py{,x} file concerning
converting values from Python objects on index assignment. ("import
struct") Is there any reason while this feature should not be on for all
such code?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20150721/8a882a58/attachment.html>


More information about the cython-devel mailing list