[Numpy-discussion] a possible way to implement a plogin system
Lisandro Dalcin
dalcinl at gmail.com
Wed Apr 30 15:45:57 EDT 2008
Sorry, I forgot to attach the code...
On 4/30/08, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> David, in order to put clear what I was proposing to you in previous
> mail regarding to implementing plugin systems for numpy, please take a
> look at the attached tarball.
>
> The plugins are in charge of implementing the action of generic foo()
> and bar() functions in C. The example actually implements two
> different plugins in Cython. There is also an include file with some
> support declarations and some macro definitions wrap_foo and wrap_bar
>
> Next, in mymodule.pyx, I define python side foo() and bar() functions
> (calling funtins pointers in a struct via the macros wrap_xxx) and a
> use() for selecting the plugin at runtime.
>
> Finally, the test.py script is pure python code showing all this in
> action. If you want to give a try, then install Cython, next do
> 'make', and finally 'python test.py'
>
> Please note that I've implemented this is Cython just for convenience,
> it does not actually depend in any special Cython feature, and could
> be translated to pure C code with Python C/API calls.
>
> IMHO, this is the easier and cleaner way to deal inside python with
> plugins written in low-level C. It does not depend explicitely on
> 'dlopen' stuff from your side.
>
> Now tell me. What is in your mind that this is not general/robust
> enough as to have to explicitely deal with dlopen? It even works on
> systems with no dynload, provided that all is put inside the python
> executable.
>
>
>
>
> --
> Lisandro Dalcín
> ---------------
> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
> Tel/Fax: +54-(0)342-451.1594
>
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stubs.tar
Type: application/x-tar
Size: 20480 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080430/cef3c8e1/attachment.tar>
More information about the NumPy-Discussion
mailing list