From 2e12d9e96a253599c90799b5537c7a0f1a07f6e0 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 3 Jan 2019 11:34:53 +0100 Subject: [PATCH] py: Try to add properties to the Host class --- src/bindings/python/simgrid_python.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index e77d5d98cc..38b0287738 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -105,8 +105,15 @@ PYBIND11_MODULE(simgrid, m) ; /* Class Host */ - py::class_>(m, "Host", "Simulation Engine, see :ref:`class s4u::Host `").def( - "by_name", &Host::by_name, "Retrieve a host from its name, or die"); + auto get_name = [](const Host* self) { + return self->get_name(); + }; + py::class_>(m, "Host", "Simulation Engine, see :ref:`class s4u::Host `") + .def("by_name", &Host::by_name, "Retrieve a host from its name, or die") + .def("get_name", &Host::get_name, "Retrieve the name of this host") + .def_property_readonly("name", get_name, "Retrieve the name of this host") + .def_property_readonly("speed", &Host::get_speed, + "Get the peak computing speed in flops/s at the current pstate, taking the external load into account, see :cpp:func:`simgrid::s4u::Host::get_speed()`"); /* Class Mailbox */ py::class_>(m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox `") -- 2.20.1