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?

user2726067
  • 131
  • 1
  • 7
  • You may want to read about the [Boost Python](http://www.boost.org/doc/libs/1_54_0/libs/python/doc/index.html) library. It can be used to both call Python code, and to create Python modules. – Some programmer dude Aug 29 '13 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) – usethedeathstar Aug 29 '13 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. – user2726067 Aug 29 '13 at 10:51
  • This subject is duplicated many times here http://stackoverflow.com/questions/49137/calling-python-from-a-c-program-for-distribution http://stackoverflow.com/questions/1417473/call-python-from-c – freude Aug 29 '13 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 ;-) – usethedeathstar Aug 29 '13 at 11:19

0 Answers0