[SciPy-Dev] sparsetools C++ code size
Evgeni Burovski
evgeny.burovskiy at gmail.com
Wed Mar 5 11:43:09 EST 2014
On Wed, Mar 5, 2014 at 4:39 PM, Robert Kern <robert.kern at gmail.com> wrote:
> On Wed, Mar 5, 2014 at 4:33 PM, Jaime Fernández del Río
> <jaime.frio at gmail.com> wrote:
>
>> I am asking out of ignorance here: if you have a templated C++ function, how
>> do you go about wrapping it to be accessible from Python?
>
> You write an `extern "C"` function that calls an explicitly
> instantiated version of the templated function.
>
> extern "C" {
>
> PyObject* my_python_function(PyObject* self, PyObject* args)
> {
> double *input_array;
> double *output_array;
> PyObject *py_output_array;
>
> input_array = ...
> output_array = ...
>
> my_templated_function<double>(input_array, output_array);
>
> py_output_array = PyArray_...(output_array);
> return py_output_array
> }
>
> }
>
> --
> Robert Kern
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
More ignorance here: what is the status of using Cython for wrapping
templated C++ code?
I mean, http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html
Evgeni
More information about the SciPy-Dev
mailing list