[Cython] Conditional import in pure Python mode
stefan_ml at behnel.de
Tue May 1 22:02:28 CEST 2012
Francesc Alted, 01.05.2012 21:49:
> On 5/1/12 2:39 PM, mark florisson wrote:
>> On 1 May 2012 20:22, Stefan Behnel wrote:
>>> Stefan Behnel, 01.05.2012 21:14:
>>>> 2) Use math.pxd as an override for the math module. I'm not sure yet how
>>>> that would best be made to work, but it shouldn't be all that complex. It
>>>> already works (mostly?) for numpy.pxd, for example, although that's done
>>>> explicitly in user code.
>>> BTW, I think it would be helpful to make the numpy.pxd cimport automatic as
>>> well whenever someone does "import numpy" and friends, right?
>> I'm not sure, it means the user has to have numpy development headers.
> But if the user is going to compile a NumPy application, it sounds like
> strange to me that she should not be required to install the NumPy
> development headers, right?
Let's say it's not impossible that someone uses NumPy and Cython without
any accelerated C level connection between the two, but it's rather
unlikely, given that Cython already has all dependencies that this
connection would require as well, except for the NumPy header files.
So I would suggest to make the automatic override the default for any
module for which a .pxd file with the same fully qualified name is found in
the search path, and to require users to explicitly disable this feature
for a given module using a module level (or external) compiler directive if
they feel like getting slower code (or working around a bug or whatever).
Anyway, given that this feature isn't even implemented yet, it may appear a
bit premature to discuss these details.
More information about the cython-devel