Sorry for my bad English, I'm new to Blender and I looked at the code many times.

As I suspect (if I'm not wrong) Blender UI is python and the core is C/C++.

For example when I want to change some features in the UI, I should do some work with python files in "bl_ui", but when I want to change Blender foundations, I should change C/C++ code

I almost know somethings about how this works but, I can't understand the connection and relationship between Python and C/C++.

When we click a button, a python file and function will be used, but what's going on after that?

I don't if know you can understand my question, I can't speak English very well, sorry.

Thank you


Using python you can import a module to use functionality inside that module. Many modules are written using python but a python module can also be a binary file similar to a shared library that was compiled from C/C++ source code. The python/C API reference at docs.python.org details how to write C code to do this.

Blender uses this C-API to provide modules that we can import from python scripts. The binary modules are merged into blender's binary file and the python interpreter built into blender takes care of giving us access to those binary modules. Most of the relevant source code can be found in source/blender/python.

So yes python is used to define blender's interface, the various functions and classes that we use may be implemented in python or C/C++, from the python scripts we run in blender we don't see any difference.


OpenGL uses PyOpenGL for binding, and everything in the API is python but still this is all wrapped to C++ inside the binary. That's what makes it difficult for developers to interact with the source code and implement things such as tesselation for the game for instance. You can find the source here

  • $\begingroup$ thank you. i have code and i compiled it ... i want to know where is the calling functions for this relationship between python and c .... python call c language from the blender core ???? an interface do this ????? i can't understand $\endgroup$ – Arash Hatami Jul 31 '16 at 5:22
  • 1
    $\begingroup$ I don't know exactly but the point is that everything you call in python is read by the core. Look for known python call inside the source and try to figure out how they get mapped to C objets. My knowledge ends hère good luck. $\endgroup$ – Yvain Jul 31 '16 at 10:51

I think you are already going to the right direction. As far as I know, Blender is using both C++ and Python for developer. For scripting especially add-on, it used Python. For developer, you can see https://wiki.blender.org/wiki/Developer_Intro/Advice. For scripting, you can see https://en.blender.org/index.php/Dev:Doc/Process/Addons. To understand better the relationship between Python and C++, you can see the Blender Python API https://docs.blender.org/api/current/info_quickstart.html.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.