0

How do I make a C++ program call Python functions?

I know how to do the opposite, where Python functions call C++ functions by using a DLL, can it be used for this as well?

5
  • You may want to read about the Boost Python library. It can be used to both call Python code, and to create Python modules. Commented Aug 29, 2013 at 10:29
  • so you want to use a faster language in which it is harder to do programming, to call a slower language in which it is easier to program (which internally calls the faster language if you use stuff like numpy) ? Can you explain a bit more in detail what you wish to do? I assume that some already implemented libraries are at the base of this problem? (I dont know much about C++, except that its faster than python but python is easier to program in, so i just wonder at the specific problem that your approach is useful) Commented Aug 29, 2013 at 10:47
  • 1
    You are right, I want to be able to combine Python and C++ in this way. When I need high performance I can write it in C++ and do the hard work. But when high performance isn't important I could be more productive in Python. So I want to combine them and let them call each other back and forth. Commented Aug 29, 2013 at 10:51
  • This subject is duplicated many times here stackoverflow.com/questions/49137/… stackoverflow.com/questions/1417473/call-python-from-c Commented Aug 29, 2013 at 10:56
  • @user2726067: write your main code in python and try scipy.weave.blitz() ? (check the documentation of it to be sure that it does what you want, but i guess it shoud) also, if you reply to peoples comment, use "@ theirusername" (but without the space) so they see in theyr inbox that they got an answer ;-) Commented Aug 29, 2013 at 11:19

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.