From cd4b49a2c8c659d3933cf902bb10e34931dbd1e7 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Thu, 17 Jun 2021 16:20:17 -0400 Subject: [PATCH] Update py::kwargs examples to pass by reference (#3038) --- docs/advanced/functions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/advanced/functions.rst b/docs/advanced/functions.rst index f6061ffbe..d880008b0 100644 --- a/docs/advanced/functions.rst +++ b/docs/advanced/functions.rst @@ -254,7 +254,7 @@ For instance, the following statement iterates over a Python ``dict``: .. code-block:: cpp - void print_dict(py::dict dict) { + void print_dict(const py::dict& dict) { /* Easily interact with Python types */ for (auto item : dict) std::cout << "key=" << std::string(py::str(item.first)) << ", " @@ -292,7 +292,7 @@ Such functions can also be created using pybind11: .. code-block:: cpp - void generic(py::args args, py::kwargs kwargs) { + void generic(py::args args, const py::kwargs& kwargs) { /// .. do something with args if (kwargs) /// .. do something with kwargs