Commit cd4b49a2 by Aaron Gokaslan Committed by GitHub

Update py::kwargs examples to pass by reference (#3038)

parent 4c7697db
...@@ -254,7 +254,7 @@ For instance, the following statement iterates over a Python ``dict``: ...@@ -254,7 +254,7 @@ For instance, the following statement iterates over a Python ``dict``:
.. code-block:: cpp .. code-block:: cpp
void print_dict(py::dict dict) { void print_dict(const py::dict& dict) {
/* Easily interact with Python types */ /* Easily interact with Python types */
for (auto item : dict) for (auto item : dict)
std::cout << "key=" << std::string(py::str(item.first)) << ", " std::cout << "key=" << std::string(py::str(item.first)) << ", "
...@@ -292,7 +292,7 @@ Such functions can also be created using pybind11: ...@@ -292,7 +292,7 @@ Such functions can also be created using pybind11:
.. code-block:: cpp .. code-block:: cpp
void generic(py::args args, py::kwargs kwargs) { void generic(py::args args, const py::kwargs& kwargs) {
/// .. do something with args /// .. do something with args
if (kwargs) if (kwargs)
/// .. do something with kwargs /// .. do something with kwargs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment