Skip to content

Commit a53a3ef

Browse files
committed
python: declare free-threading support in graph modules
Add pybind11::mod_gil_not_used() to the min_cost_flow, max_flow and linear_sum_assignment modules so that importing them on a free-threaded CPython build (3.13t/3.14t) no longer re-enables the GIL.
1 parent cf81a97 commit a53a3ef

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

ortools/graph/python/linear_sum_assignment.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using ::operations_research::SimpleLinearSumAssignment;
2020
using NodeIndex = ::operations_research::SimpleLinearSumAssignment::NodeIndex;
2121
using ::pybind11::arg;
2222

23-
PYBIND11_MODULE(linear_sum_assignment, m) {
23+
PYBIND11_MODULE(linear_sum_assignment, m, pybind11::mod_gil_not_used()) {
2424
pybind11::class_<SimpleLinearSumAssignment> slsa(m,
2525
"SimpleLinearSumAssignment");
2626
slsa.def(pybind11::init<>());

ortools/graph/python/max_flow.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
using ::operations_research::SimpleMaxFlow;
2323
using ::pybind11::arg;
2424

25-
PYBIND11_MODULE(max_flow, m) {
25+
PYBIND11_MODULE(max_flow, m, pybind11::mod_gil_not_used()) {
2626
pybind11::class_<SimpleMaxFlow> smf(m, "SimpleMaxFlow");
2727
smf.def(pybind11::init<>());
2828
smf.def("add_arc_with_capacity", &SimpleMaxFlow::AddArcWithCapacity,

ortools/graph/python/min_cost_flow.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using ::operations_research::MinCostFlowBase;
2121
using ::operations_research::SimpleMinCostFlow;
2222
using ::pybind11::arg;
2323

24-
PYBIND11_MODULE(min_cost_flow, m) {
24+
PYBIND11_MODULE(min_cost_flow, m, pybind11::mod_gil_not_used()) {
2525
pybind11::class_<SimpleMinCostFlow> smcf(m, "SimpleMinCostFlow");
2626
smcf.def(pybind11::init<>());
2727
smcf.def("add_arc_with_capacity_and_unit_cost",

0 commit comments

Comments
 (0)