Search code examples
pythoncpyc

Can C run compiled Python code (.pyc files)?


Considering that the main Python implementation CPython written in C, and libraries exist that can convert Python code to C, would it be possible to run compiled Python bytecode in C or C++?


Solution

  • First, you cannot run anything in C, C is a programming language. You can embed python in your C program (see Documentation), because python can be compiled as library. But Python is not only the pyc-File, but consists of many modules, that make python as powerful as it is.