Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-06 Thread Glen W. Mabey
On Wed, Feb 06, 2008 at 03:23:43AM -0600, Kent-Andre Mardal wrote: > No problem, it is now under BSD. OK? Perfect. Thank you. Glen ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-06 Thread Sebastian Haase
How does Instant compare to scipy.weave !? -Sebastian Haase On Feb 5, 2008 11:26 PM, Glen W. Mabey <[EMAIL PROTECTED]> wrote: > On Tue, Feb 05, 2008 at 12:16:02PM -0600, Kent-Andre Mardal wrote: > > We have created a small Python module Instant (www.fenics.org/instant) on > > top > > of SWIG,

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Glen W. Mabey
On Tue, Feb 05, 2008 at 12:16:02PM -0600, Kent-Andre Mardal wrote: > We have created a small Python module Instant (www.fenics.org/instant) on top > of SWIG, which makes integration of C/C++ and NumPy arrays easy in some cases. Hello, Thank you for posting about instant. I think it looks like a

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Damian Eads
Dear Vince, You probably have heard better solutions but I think what I do works and is simple to learn. When I need to call C++ code from Python, I write a wrapper extern "C" function that calls the C++ function that returns the result. Then I just use ctypes to call the extern "C" function fr

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Kent-Andre Mardal
Vince Fulco gmail.com> writes: > > Dear Numpy Experts- I find myself working with Numpy arrays and > wanting to access *simple* C++ functions for time series returning the > results to Numpy. As I am a relatively new user of Python/Numpy, the > number of paths to use in incorporating C++ code

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Lou Pecora
--- Gael Varoquaux <[EMAIL PROTECTED]> wrote: Re: ctypes > I don't use windows much. One thing I liked about > ctypes when I used it, > was that what I found it pretty easy to get working > on both Linux and > Windows. > > Gaël I got ctypes to install easily on Mac OS X 10.4.11 and it passe

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Gael Varoquaux
On Tue, Feb 05, 2008 at 06:45:25AM -0800, Lou Pecora wrote: > Hmmm... last time I tried ctypes it seemed pretty > Windows oriented and I got nowhere. But enough people > have said how easy it is that I'll give it another > try. I don't use windows much. One thing I liked about ctypes when I used

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Lou Pecora
Hmmm... last time I tried ctypes it seemed pretty Windows oriented and I got nowhere. But enough people have said how easy it is that I'll give it another try. Believe me, I'd be happy to be wrong and find a nice easy way to pass NumPy arrays and such. Thanks. -- Lou Pecora --- Gael Varoquaux

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Ondrej Certik
On Feb 5, 2008 11:52 AM, Gael Varoquaux <[EMAIL PROTECTED]> wrote: > On Tue, Feb 05, 2008 at 11:48:38AM +0100, Ondrej Certik wrote: > > I use Cython, mostly for the same reasons Gael is using ctypes - it's > > trivial. > > Actually, when I want to do something really trivial, I use > scipy.weave.i

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread David Cournapeau
Gael Varoquaux wrote: > On Tue, Feb 05, 2008 at 11:48:37AM +0100, Sebastian Haase wrote: >> Thanks fr the reply. >> How about "manual" overloading. I mean, if -- for example -- I have >> two functions mmms_b and mmms_i in C, I could still use ctypes; could >> I then "merge" them into one python fun

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Matthieu Brucher
> > This is what SWIG must be doing internally -- right ?! > Yes, it is with an additional typemap that checks the type of the data. I don't think that it is a good idea for numpy to add such multi-dispatching, it is not its job. There are a lot of ways to do it, and besides it would be very cumb

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Gael Varoquaux
On Tue, Feb 05, 2008 at 11:48:38AM +0100, Ondrej Certik wrote: > I use Cython, mostly for the same reasons Gael is using ctypes - it's trivial. Actually, when I want to do something really trivial, I use scipy.weave.inline ( see http://scipy.org/PerformancePython for an example of scipy.weave.inli

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Gael Varoquaux
On Tue, Feb 05, 2008 at 11:48:37AM +0100, Sebastian Haase wrote: > Thanks fr the reply. > How about "manual" overloading. I mean, if -- for example -- I have > two functions mmms_b and mmms_i in C, I could still use ctypes; could > I then "merge" them into one python function, which "re-routes" > d

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Ondrej Certik
On Feb 5, 2008 11:23 AM, David Cournapeau <[EMAIL PROTECTED]> wrote: > Gael Varoquaux wrote: > > On Tue, Feb 05, 2008 at 09:15:29AM +0100, Sebastian Haase wrote: > > > >> Can ctypes do this ? > >> > > > > No. Ctypes is only a way of loading C (and not C++) libraries in Python. > > That makes it ver

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Sebastian Haase
On Feb 5, 2008 9:21 AM, Gael Varoquaux <[EMAIL PROTECTED]> wrote: > On Tue, Feb 05, 2008 at 09:15:29AM +0100, Sebastian Haase wrote: > > Can ctypes do this ? > > No. Ctypes is only a way of loading C (and not C++) libraries in Python. > That makes it very simple, but not very powerful. > > Gaël (so

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread David Cournapeau
Gael Varoquaux wrote: > On Tue, Feb 05, 2008 at 09:15:29AM +0100, Sebastian Haase wrote: > >> Can ctypes do this ? >> > > No. Ctypes is only a way of loading C (and not C++) libraries in Python. > That makes it very simple, but not very powerful. > I would not call ctypes not very powerf

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Gael Varoquaux
On Tue, Feb 05, 2008 at 09:15:29AM +0100, Sebastian Haase wrote: > Can ctypes do this ? No. Ctypes is only a way of loading C (and not C++) libraries in Python. That makes it very simple, but not very powerful. Gaël ___ Numpy-discussion mailing list Num

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-05 Thread Sebastian Haase
On Feb 4, 2008 9:05 PM, Christopher Barker <[EMAIL PROTECTED]> wrote: > Lou Pecora wrote: > > I > > would recommend using the C API > > I would recommend against this -- there is a lot of code to write in > extensions to make sure you do reference counting, etc, and it is hard > to get right. > > M

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Phil Austin
Bill Spotz wrote: > On Feb 4, 2008, at 1:05 PM, Christopher Barker wrote: > >> Boost::python -- best for writing custom extensions in C++ -- also can >> be used for interfacing with legacy C++. There were boost array >> classes >> for numpy -- are these being maintained? > > There are boo

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Barry Wark
For comparison of ctypes and SWIG wrappers of a simple C++ codebase, feel free to take a look at the code for scikits.ann (http://scipy.org/scipy/scikits/wiki/AnnWrapper). The original wrapper was written using SWIG and the numpy typemaps. Rob Hetland has coded an almost-the-same API wrapper using

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Gael Varoquaux
On Mon, Feb 04, 2008 at 12:49:58PM -0800, Lou Pecora wrote: > So, for those looking for speed up through some > external C or C++ code, I would say (trying to be fair > here), try what Chris recommends below, if you want, > but IMHO, none of it is trivial. If you get it to > work, great. If not,

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Lou Pecora
--- Christopher Barker <[EMAIL PROTECTED]> wrote: > Lou Pecora wrote: > > I > > would recommend using the C API > > I would recommend against this -- there is a lot of > code to write in > extensions to make sure you do reference counting, > etc, and it is hard > to get right. Well, fair enou

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Gael Varoquaux
On Mon, Feb 04, 2008 at 12:05:45PM -0800, Christopher Barker wrote: > ctypes -- [...] Can it call C++ directly at all? No, but you can use 'extern "C"' in you cpp file, if you have controle over the file. Gaël ___ Numpy-discussion mailing list Numpy-dis

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Neal Becker
Christopher Barker wrote: > Neal Becker wrote: >> I have a variety of experiments that I put in this mercurial repo: >> https://nbecker.dyndns.org/hg/ >> >> The primary aim of this is to reuse c++ code written to a generic >> container interface, with numpy. > > Neal, > > I'd love to hear more

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Bill Spotz
On Feb 4, 2008, at 1:05 PM, Christopher Barker wrote: > Boost::python -- best for writing custom extensions in C++ -- also can > be used for interfacing with legacy C++. There were boost array > classes > for numpy -- are these being maintained? There are boost array classes for Numeric, and *t

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Christopher Barker
Neal Becker wrote: > I have a variety of experiments that I put in this mercurial repo: > https://nbecker.dyndns.org/hg/ > > The primary aim of this is to reuse c++ code written to a generic container > interface, with numpy. Neal, I'd love to hear more about this. Do you have a two paragraph d

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Christopher Barker
Lou Pecora wrote: > I > would recommend using the C API I would recommend against this -- there is a lot of code to write in extensions to make sure you do reference counting, etc, and it is hard to get right. Much of it is also boiler-plate code, so it makes more sense to have that code auto-

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Bill Spotz
On Feb 4, 2008, at 9:39 AM, Matthieu Brucher wrote: > This can be avoided, but you'll have to use more powerful tools. I > would advice SWIG (see my blog for some examples with C++ and SWIG). Note that a lot of work has been done to bridge between numpy and swig. There is a swig interface f

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Neal Becker
I have a variety of experiments that I put in this mercurial repo: https://nbecker.dyndns.org/hg/ The primary aim of this is to reuse c++ code written to a generic container interface, with numpy. ___ Numpy-discussion mailing list Numpy-discussion@scip

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Lou Pecora
--- Matthieu Brucher <[EMAIL PROTECTED]> wrote: > Whatever solution you choose (Boost.Python, ...), > you will have to use the > Numpy C API at least a little bit. So Travis' book > is a good start. As Gaël > told you, you can use ctypes if you wrap manually > every method with a C > function an

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Matthieu Brucher
2008/2/4, Lou Pecora <[EMAIL PROTECTED]>: > > Dear Mr. Fulco , > > This may not be exactly what you want to do, but I > would recommend using the C API and then calling your > C++ programs from there (where interface functions to > the C++ code is compiled in the extern "C" {, } > block. I will b

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Lou Pecora
Dear Mr. Fulco , This may not be exactly what you want to do, but I would recommend using the C API and then calling your C++ programs from there (where interface functions to the C++ code is compiled in the extern "C" {, } block. I will be doing this soon with my own project. Why? Because t

Re: [Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Gael Varoquaux
On Mon, Feb 04, 2008 at 11:02:29AM -0500, Vince Fulco wrote: > Any trailheads for the simplest approach I find ctypes very easy to understand. See http://www.scipy.org/Cookbook/Ctypes for simple instructions. HTH, Gaël ___ Numpy-discussion mailing list

[Numpy-discussion] Numpy and C++ integration...

2008-02-04 Thread Vince Fulco
Dear Numpy Experts- I find myself working with Numpy arrays and wanting to access *simple* C++ functions for time series returning the results to Numpy. As I am a relatively new user of Python/Numpy, the number of paths to use in incorporating C++ code into one's scripts is daunting. I've attemp