[Numpy-discussion] numpy gsoc ideas (was: numpy gsoc topic idea: configurable algorithm precision and vector math library integration)

Nathaniel Smith njs at pobox.com
Thu Mar 6 08:45:36 EST 2014


On Thu, Mar 6, 2014 at 5:17 AM, Sturla Molden <sturla.molden at gmail.com> wrote:
> Nathaniel Smith <njs at pobox.com> wrote:
>
>> 3. Using Cython in the numpy core
>>
>> The numpy core contains tons of complicated C code implementing
>> elaborate operations like indexing, casting, ufunc dispatch, etc. It
>> would be really nice if we could use Cython to write some of these
>> things.
>
> So the idea of having a NumPy as a pure C library in the core is abandoned?

This question doesn't make sense to me so I think I must be missing
some context.

Nothing is abandoned: This is one email by one person on one mailing
list suggesting a project to the explore the feasibility of something.
And anyway, Cython is just a C code generator, similar in principle to
(though vastly more sophisticated than) the ones we already use. It's
not like we've ever promised our users we'll keep stable which kind of
code generators we use internally.

>>  However, there is a practical problem: Cython assumes that
>> each .pyx file generates a single compiled module with its own
>> Cython-defined API. Numpy, however, contains a large number of .c
>> files which are all compiled together into a single module, with its
>> own home-brewed system for defining the public API. And we can't
>> rewrite the whole thing. So for this to be viable, we would need some
>> way to compile a bunch of .c *and .pyx* files together into a single
>> module, and allow the .c and .pyx files to call each other.
>
> Cython takes care of that already.
>
> http://docs.cython.org/src/userguide/sharing_declarations.html#cimport
>
> http://docs.cython.org/src/userguide/external_C_code.html#using-cython-declarations-from-c

Linking multiple .c and .pyx files together into a single .so/.dll is
much more complicated than just using 'cimport'. Try it if you don't
believe me :-).

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org



More information about the NumPy-Discussion mailing list