diff --git a/bindings/python/src/real.hpp b/bindings/python/src/real.hpp index 83642149..72a0dc30 100644 --- a/bindings/python/src/real.hpp +++ b/bindings/python/src/real.hpp @@ -77,14 +77,12 @@ inline T py_floordiv(const T1& x, const T2& y) template void py_real(py::module_& m) { - auto& c = py::class_(m, "Real", py::dynamic_attr(), - "active arithmetic type for first order adjoint mode") - .def(py::init()) - .def(py::init<>()); + auto c = py::class_(m, "Real", py::dynamic_attr(), + "active arithmetic type for first order adjoint mode"); - add_extra_methods(c); - - c.def(py::self == py::self) + c.def(py::init()) + .def(py::init<>()) + .def(py::self == py::self) .def(py::self != py::self) .def(py::self >= py::self) .def(py::self <= py::self) @@ -193,4 +191,6 @@ void py_real(py::module_& m) "real", [](const T& x) { return x; }, "real part") .def( "imag", [](const T&) { return T(0.0); }, "imaginary part"); + + add_extra_methods(c); }