[Numpy-discussion] How a transition to C++ could work

Mark Wiebe mwwiebe@gmail....
Sun Feb 19 02:59:40 CST 2012

On Sun, Feb 19, 2012 at 2:51 AM, Stéfan van der Walt <stefan@sun.ac.za>wrote:

> On Feb 19, 2012 12:34 AM, "Mark Wiebe" <mwwiebe@gmail.com> wrote:
> >
> > I'm speaking from personal experience having dealt with these types of
> issues extensively before. If people have more detailed examples of
> problems, possibly links to discussions where one of these problems has
> occurred, that would be helpful. This argument isn't very useful if it's
> just my positive experience versus others negative experience, we need to
> get into specifics to advance the discussion.
> Wow, the NumPy list has gotten so serious :) I'm certainly not doubting
> anyone's experience--just trying to get a handle on possible transition
> risks.
> Heh, when threads get longer than 50 message, I think that's a sign
something is serious!

> OK, so let's talk specifics: how do you dynamically grab a function
> pointer to a compiled C++ library, a la ctypes? Feel free to point me to
> StackOverflow or elsewhere.
If the C++ library is exposing a C-API, it's identical to the case for C.

If it's not, and you must access the functions via ctypes anyway, you need
to determine the mangled name of the function. The mangled name encodes the
types of the parameters, to support function polymorphism, and is different
for each OS platform. Also, if the function takes a class object as a
parameter, or returns one, ctypes doesn't give you a way to forward that

In general, the standard advice is to wrap the C++ library using
Boost.Python, Cython, or something similar. Dealing directly with the
mangled names, while possible, is not likely to make you happy.


>  Stéfan
> _______________________________________________
> 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/20120219/22365476/attachment.html 

More information about the NumPy-Discussion mailing list