diff --git a/bindings/python/google_benchmark/benchmark.cc b/bindings/python/google_benchmark/benchmark.cc index 64ffb92b4..a93582253 100644 --- a/bindings/python/google_benchmark/benchmark.cc +++ b/bindings/python/google_benchmark/benchmark.cc @@ -118,7 +118,7 @@ NB_MODULE(_benchmark, m) { using benchmark::Counter; nb::class_ py_counter(m, "Counter"); - nb::enum_(py_counter, "Flags", nb::is_arithmetic()) + nb::enum_(py_counter, "Flags", nb::is_arithmetic(), nb::is_flag()) .value("kDefaults", Counter::Flags::kDefaults) .value("kIsRate", Counter::Flags::kIsRate) .value("kAvgThreads", Counter::Flags::kAvgThreads) @@ -129,10 +129,7 @@ NB_MODULE(_benchmark, m) { .value("kAvgIterations", Counter::Flags::kAvgIterations) .value("kAvgIterationsRate", Counter::Flags::kAvgIterationsRate) .value("kInvert", Counter::Flags::kInvert) - .export_values() - .def("__or__", [](Counter::Flags a, Counter::Flags b) { - return static_cast(a) | static_cast(b); - }); + .export_values(); nb::enum_(py_counter, "OneK") .value("kIs1000", Counter::OneK::kIs1000) @@ -140,13 +137,9 @@ NB_MODULE(_benchmark, m) { .export_values(); py_counter - .def( - "__init__", - [](Counter* c, double value, int flags, Counter::OneK oneK) { - new (c) Counter(value, static_cast(flags), oneK); - }, - nb::arg("value") = 0., nb::arg("flags") = Counter::kDefaults, - nb::arg("k") = Counter::kIs1000) + .def(nb::init(), + nb::arg("value") = 0., nb::arg("flags") = Counter::kDefaults, + nb::arg("k") = Counter::kIs1000) .def("__init__", ([](Counter* c, double value) { new (c) Counter(value); })) .def_rw("value", &Counter::value)