0

Can I program in Python and use a code made in C ++? Could I see some example?

So it was with the C language and the assembly language. It was more efficient to program in C language, but if it was necessary to optimize some part, it was reprogrammed in the assembly language.

31st Jul 2017, 3:53 PM
Jorge Grave de Peralta
Jorge Grave de Peralta - avatar
3 Réponses
+ 4
This page includes a simple example: https://docs.python.org/3/extending/extending.html "The library contains built-in modules (written in C)": https://docs.python.org/3/library/index.html
26th Aug 2017, 1:52 AM
hamletmun
hamletmun - avatar
+ 2
@jorge Grave is absolutely right, you can make most of your program with python and only optimize a small part ( let's say a single function that will manage a heavier process, or you need speed improvement) and then back to python hope it helps you
25th Aug 2017, 11:39 PM
AldoS
AldoS - avatar
+ 1
Yes, you can. It is very common to happen in industry. One example is to use Python to create graphics and interface, read input and store it in a file. Then, call a C++ program to make a heavy processing in the file (for example, finding shortest path between two points) and create a result file. The result file is then read by the first python program that prints the output graphically in the UI.
31st Jul 2017, 11:24 PM
Denis Felipe
Denis Felipe - avatar