[Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray <=> numpy.array typemap to share?

Matthieu Brucher matthieu.brucher@gmail....
Mon Sep 10 13:59:30 CDT 2007


>
> OK, so you've now got a view of the data from the valarray. Nice to know
> this works, but, of course, fragile if the valarray is re-sized or
> anything, so it probably won't work for us.
>

Unless you use a special allocator/desallocator (I don't know if the latter
is possible), I don't know how you could first correctly share the pointer
(as you said, if the valarray is resized or deleted, you lose your memory).
If you want to have a correct implementation (robust to array deletion,
resizing in Python and C++), you should use shared pointers, and I don't
know if you can build a vector with a shared pointer (perhaps with the
special allocator/desallocator, but then it does not work with std::set,
std::list or std::map).

Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070910/cfe4f7f4/attachment.html 


More information about the Numpy-discussion mailing list