Search code examples
pythonapibindinggurobi

How does gurobi handle python API calls to C?


As it's discussed in gurobi documentation, gurobi engine is written in the C language. However, all languages supported by gurobi (Python, Java, Matlab, C#, and so on) provide an interface to gurobi engine and no heavy computation is performed in the API interface.

Considering Python, my question is how gurobipy makes the API calls to the C code from python. I read about it a little bit and I don't think they use SWIG or similar tools. I'd be thankful if somebody can clarify this to me.

Thank you all


Solution

  • You are correct that the Gurobi solver is written in C. Gurobi currently provides APIs for C++, Java, .NET, Python, MATLAB and R; each of these call the C API directly. For Python, Gurobi provides Python classes that represent optimization models. These classes pass data and solutions to the Gurobi C API using Cython.

    This only describes the Gurobi APIs; open-source APIs such as Pyomo or PuLP work differently.