[Numpy-discussion] request for SWIG numpy.i users

Egor Zindy ezindy@gmail....
Fri Jun 7 00:57:13 CDT 2013


Hi Ralf,

Your post comes just on time! I implemented the memory managed arrays and
noticed a serious problem with my capsule creation code (post I sent to the
list about the update on the 12th of March in reply to Bill Spotz "Request
code review of numpy.i changes"). For some reason, the code I wrote works
under Linux (or at least on my 12.04 ubuntu machine) but crashes in Windows
/ mingw-64, something I just found out about this week.

Specifically, "SWIG_Python_DestroyModule" seems to be the wrong function
call for the capsule and cobject destructor and I am really not sure why
the code worked when I was using testing it on my Linux machine.

I should have a bit of time over the week-end to look into this and a
couple of other things.

Anyway, for PyCObject_FromVoidPtr(), the destructor should be a call to
free() and for PyCapsule_New(), the destructor code should be a call to a
free_cap() function with the following content:

%#ifdef SWIGPY_USE_CAPSULE
  void free_cap(PyObject * cap)
  {
    void* array = (void*) PyCapsule_GetPointer(cap,SWIGPY_CAPSULE_NAME);
    if (array != NULL) free(array);
  }
%#endif

This works both in Linux and Windows / mingw-64.

I'll ping the list when I'm done testing.

Kind regards,
Egor

On 4 June 2013 21:13, Ralf Gommers <ralf.gommers@gmail.com> wrote:

> Hi,
>
> If you're using or are very familiar with SWIG and the numpy.i interface
> to it, please help to test and/or review
> https://github.com/numpy/numpy/pull/3148. It's a fairly major update to
> numpy.i by Bill Spotz, containing the following:
>   - support for 4D arrays and memory managed output arguments
>   - rework for the deprecated API's in numpy 1.6 and 1.7
>   - a bug fix in a 3D typemap
>   - documentation improvements
>
> It would be good to have this merged before branching 1.8.x. Not many of
> the regular reviewers of numpy PRs are familiar with numpy.i, therefore
> help would be much appreciated.
>
> Thanks,
> Ralf
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130607/4498328b/attachment.html 


More information about the NumPy-Discussion mailing list