[SciPy-User] CGAL wrapping: cython vs boost vs SWIG

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[SciPy-User] CGAL wrapping: cython vs boost vs SWIG

Guillaume Gay

Hi all,

I'm starting a modeling project emanating from a previous one. While the original project was based on graph-tool, I now want to have more hands on the C++ side of things.

Particularly, CGAL LinearCellComplex library is well suited for my modeling needs.

The basic needs I have are:

  • Access from python to custom iterators defined in C++ (over the cells of the LCC, one cell's edges, and so on)

  • The ability to manipulate attributes of the LinearCellComplex (associated with edges, vertices or faces) from python as ndarrays or even better pandas DataFrames, ideally without the need to copy data, such that modifications of these attributes are synchronized between the two languages

For now, the project is using Boost.Python for the wrapping, but I got a bit confused with the ndarray side of things, as there are two projects claiming to provide interfaces between numpy and boost:

They don't seem very active, nor very documented…

I used SWIG before, but keep a very bad memory of the experience ;)

So, would Cython be more adapted? My guess is, as the numpy interface is ingrained in Cython, that would be easier, but what about iterators?

Any advice or previous experience on similar issues welcome.

Best,

Guillaume

-- 

--
Guillaume Gay, PhD

http://damcb.com

43 rue Horace Bertin
13005 Marseille

+33 953 55 98 89
+33 651 95 94 00

n°SIRET 751 175 233 00020

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: CGAL wrapping: cython vs boost vs SWIG

Jason Moore
Cython has great numpy support but it is not an automatic wrapping tool. You will have to manually wrap everything you want available in Python. This is a Cython based automatic wrapping tool that could be useful too: https://github.com/xdress/xdress.


Jason
moorepants.info
+01 530-601-9791

On Fri, Jul 17, 2015 at 2:00 AM, Guillaume Gay <[hidden email]> wrote:

Hi all,

I'm starting a modeling project emanating from a previous one. While the original project was based on graph-tool, I now want to have more hands on the C++ side of things.

Particularly, CGAL LinearCellComplex library is well suited for my modeling needs.

The basic needs I have are:

  • Access from python to custom iterators defined in C++ (over the cells of the LCC, one cell's edges, and so on)

  • The ability to manipulate attributes of the LinearCellComplex (associated with edges, vertices or faces) from python as ndarrays or even better pandas DataFrames, ideally without the need to copy data, such that modifications of these attributes are synchronized between the two languages

For now, the project is using Boost.Python for the wrapping, but I got a bit confused with the ndarray side of things, as there are two projects claiming to provide interfaces between numpy and boost:

They don't seem very active, nor very documented…

I used SWIG before, but keep a very bad memory of the experience ;)

So, would Cython be more adapted? My guess is, as the numpy interface is ingrained in Cython, that would be easier, but what about iterators?

Any advice or previous experience on similar issues welcome.

Best,

Guillaume

-- 

--
Guillaume Gay, PhD

http://damcb.com

43 rue Horace Bertin
13005 Marseille

+33 953 55 98 89
+33 651 95 94 00

n°SIRET 751 175 233 00020

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user



_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: CGAL wrapping: cython vs boost vs SWIG

Guillaume Gay
Thanks Jason,

As far as I understand it, boost.python isn't automatic either, you have to export all you need explicitly.

I'll have a look at xdress, but their doc hosting website (xdress.org) is down, more like squatted by advertising links , actually :(

G.

Le 17/07/2015 17:02, Jason Moore a écrit :
Cython has great numpy support but it is not an automatic wrapping tool. You will have to manually wrap everything you want available in Python. This is a Cython based automatic wrapping tool that could be useful too: https://github.com/xdress/xdress.


Jason
moorepants.info
+01 530-601-9791

On Fri, Jul 17, 2015 at 2:00 AM, Guillaume Gay <[hidden email]> wrote:

Hi all,

I'm starting a modeling project emanating from a previous one. While the original project was based on graph-tool, I now want to have more hands on the C++ side of things.

Particularly, CGAL LinearCellComplex library is well suited for my modeling needs.

The basic needs I have are:

  • Access from python to custom iterators defined in C++ (over the cells of the LCC, one cell's edges, and so on)

  • The ability to manipulate attributes of the LinearCellComplex (associated with edges, vertices or faces) from python as ndarrays or even better pandas DataFrames, ideally without the need to copy data, such that modifications of these attributes are synchronized between the two languages

For now, the project is using Boost.Python for the wrapping, but I got a bit confused with the ndarray side of things, as there are two projects claiming to provide interfaces between numpy and boost:

They don't seem very active, nor very documented…

I used SWIG before, but keep a very bad memory of the experience ;)

So, would Cython be more adapted? My guess is, as the numpy interface is ingrained in Cython, that would be easier, but what about iterators?

Any advice or previous experience on similar issues welcome.

Best,

Guillaume

-- 

--
Guillaume Gay, PhD

http://damcb.com

43 rue Horace Bertin
13005 Marseille

+33 953 55 98 89
+33 651 95 94 00

n°SIRET 751 175 233 00020

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user




_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user

-- 

--
Guillaume Gay, PhD

http://damcb.com

43 rue Horace Bertin
13005 Marseille

+33 953 55 98 89
+33 651 95 94 00

n°SIRET 751 175 233 00020

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: CGAL wrapping: cython vs boost vs SWIG

Chris Barker - NOAA Federal
Cyton is a great option.

It is hand wrapping, so you'll be writing a fair bit of boilerplate, but it does let you create a nice customized python wrapper -- with the auto-wrapping tools, you need to hand-write a bunch of stuff to do that anyway, and SWIG, at least, makes that quite painful.

I'd at least give XDress a try -- if it works, it could be great, but it's not a terribly mature project.

-Chris





On Fri, Jul 17, 2015 at 8:13 AM, Guillaume Gay <[hidden email]> wrote:
Thanks Jason,

As far as I understand it, boost.python isn't automatic either, you have to export all you need explicitly.

I'll have a look at xdress, but their doc hosting website (xdress.org) is down, more like squatted by advertising links , actually :(

G.


Le 17/07/2015 17:02, Jason Moore a écrit :
Cython has great numpy support but it is not an automatic wrapping tool. You will have to manually wrap everything you want available in Python. This is a Cython based automatic wrapping tool that could be useful too: https://github.com/xdress/xdress.


Jason
moorepants.info
+01 <a href="tel:530-601-9791" value="+15306019791" target="_blank">530-601-9791

On Fri, Jul 17, 2015 at 2:00 AM, Guillaume Gay <[hidden email]> wrote:

Hi all,

I'm starting a modeling project emanating from a previous one. While the original project was based on graph-tool, I now want to have more hands on the C++ side of things.

Particularly, CGAL LinearCellComplex library is well suited for my modeling needs.

The basic needs I have are:

  • Access from python to custom iterators defined in C++ (over the cells of the LCC, one cell's edges, and so on)

  • The ability to manipulate attributes of the LinearCellComplex (associated with edges, vertices or faces) from python as ndarrays or even better pandas DataFrames, ideally without the need to copy data, such that modifications of these attributes are synchronized between the two languages

For now, the project is using Boost.Python for the wrapping, but I got a bit confused with the ndarray side of things, as there are two projects claiming to provide interfaces between numpy and boost:

They don't seem very active, nor very documented…

I used SWIG before, but keep a very bad memory of the experience ;)

So, would Cython be more adapted? My guess is, as the numpy interface is ingrained in Cython, that would be easier, but what about iterators?

Any advice or previous experience on similar issues welcome.

Best,

Guillaume

-- 

--
Guillaume Gay, PhD

http://damcb.com

43 rue Horace Bertin
13005 Marseille

+33 953 55 98 89
+33 651 95 94 00

n°SIRET 751 175 233 00020

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user




_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user

-- 

--
Guillaume Gay, PhD

http://damcb.com

43 rue Horace Bertin
13005 Marseille

+33 953 55 98 89
+33 651 95 94 00

n°SIRET 751 175 233 00020

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user




--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user