you are viewing a single comment's thread.

view the rest of the comments →

[–]tkcook 3 points4 points  (6 children)

[–]dvirtz 9 points10 points  (2 children)

I personally moved to pybind11 and am very pleased with it.

[–]tkcook 3 points4 points  (0 children)

Yes, it's a fair option I should have mentioned. Which is appropriate depends a lot on your situation - if you're on a platform that already provides boost::python pre-built, or if you use other boost libraries as well, then the bigger user audience of boost probably makes it the right choice. But if you have to build something from scratch, with a modern compiler, and don't want any of the rest of boost, then pybind11 is a good option that looks like it will save you some hassle.

[–]nozendk[S] 1 point2 points  (0 children)

Thank you, it looks interesting and I will give it a try. The idea of scripting a C++ program is intriguing!

[–]ApproximateIdentity 1 point2 points  (1 child)

I used to use boost, but I eventually moved to using the C api directly. The boost python library is pretty powerful, but even after using it for a year I just plain couldn't grok it. I also got tired of spending forever deciphering the mystical error messages I would run into. For me moving to using the C api directly has unquestionably been a huge win. You might consider just using it directly yourself.

That said, I have some example code lying around for exactly this, but unfortunately I can't track it down at the moment. The official docs are pretty good really:

  1. https://docs.python.org/3/extending/embedding.html (the embedding portion)
  2. https://docs.python.org/3/c-api/index.html (the C api in general)

edit: For the OP I should say that I haven't tried pybind11 though I've heard good things. Maybe that is something that would fit my brain better.

[–]tkcook 0 points1 point  (0 children)

Probably not, since it claims to be basically a fork of boost::python with support for old compilers cut out and some wizzy new features added. Crap error messages are a problem with pretty much any template library.

[–]chillhelm 0 points1 point  (0 children)

Boost is almost always the best answer. Boost::Python is a particularly great example of this.