Skip to content

Python C API

Ashwin Vangipuram edited this page Sep 26, 2020 · 2 revisions

Python's C API

For those who are unaware, the Python interpreter is actually written in C. As a result, they have created many C functions that can be used to create and interact with Python objects (which are also really C). We use this API to create the Python interpreter within a C program and run Python code directly in a C program, which is called embedding the interpreter. This is used only in executor.c so that we can execute the student code which is written in Python. To learn all about the API, check out the documentation https://docs.python.org/3.7/c-api/index.html.

This intro will also give a good overview of how exactly to use the API in general https://docs.python.org/3.7/c-api/intro.html. We will also list all the important docs to read: