Skip to content

Commit 8e93df8

Browse files
committed
minor clarification regarding keep_alive; fixed some typos
1 parent c993bce commit 8e93df8

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

docs/advanced.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,13 @@ specified to indicate dependencies between parameters. There is currently just
515515
one policy named ``keep_alive<Nurse, Patient>``, which indicates that the
516516
argument with index ``Patient`` should be kept alive at least until the
517517
argument with index ``Nurse`` is freed by the garbage collector; argument
518-
indices start at one, while zero refers to the return value. Arbitrarily many
519-
call policies can be specified.
518+
indices start at one, while zero refers to the return value. For methods, index
519+
one refers to the implicit ``this`` pointer, while regular arguments begin at
520+
index two. Arbitrarily many call policies can be specified.
520521

521-
For instance, binding code for a a list append operation that ties the lifetime
522-
of the newly added element to the underlying container might be declared as
523-
follows:
522+
Consider the following example: the binding code for a list append operation
523+
that ties the lifetime of the newly added element to the underlying container
524+
might be declared as follows:
524525

525526
.. code-block:: cpp
526527
@@ -542,7 +543,7 @@ Implicit type conversions
542543
=========================
543544

544545
Suppose that instances of two types ``A`` and ``B`` are used in a project, and
545-
that an ``A`` can easily be converted into a an instance of type ``B`` (examples of this
546+
that an ``A`` can easily be converted into an instance of type ``B`` (examples of this
546547
could be a fixed and an arbitrary precision number type).
547548

548549
.. code-block:: cpp
@@ -815,7 +816,7 @@ we want to bind the following simplistic Matrix class:
815816
};
816817
817818
The following binding code exposes the ``Matrix`` contents as a buffer object,
818-
making it possible to cast Matrixes into NumPy arrays. It is even possible to
819+
making it possible to cast Matrices into NumPy arrays. It is even possible to
819820
completely avoid copy operations with Python expressions like
820821
``np.array(matrix_instance, copy = False)``.
821822

@@ -930,7 +931,7 @@ After including the ``pybind11/numpy.h`` header, this is extremely simple:
930931
m.def("vectorized_func", py::vectorize(my_func));
931932
932933
Invoking the function like below causes 4 calls to be made to ``my_func`` with
933-
each of the the array elements. The significant advantage of this compared to
934+
each of the array elements. The significant advantage of this compared to
934935
solutions like ``numpy.vectorize()`` is that the loop over the elements runs
935936
entirely on the C++ side and can be crunched down into a tight, optimized loop
936937
by the compiler. The result is returned as a NumPy array of type
@@ -948,7 +949,7 @@ arrays ``x`` and ``y`` are automatically converted into the right types (they
948949
are of type ``numpy.dtype.int64`` but need to be ``numpy.dtype.int32`` and
949950
``numpy.dtype.float32``, respectively)
950951

951-
Sometimes we might want to explitly exclude an argument from the vectorization
952+
Sometimes we might want to explicitly exclude an argument from the vectorization
952953
because it makes little sense to wrap it in a NumPy array. For instance,
953954
suppose the function signature was
954955

@@ -1255,7 +1256,7 @@ the declaration
12551256
12561257
PYBIND11_MAKE_OPAQUE(std::vector<int>);
12571258
1258-
before any binding code (e.g. invocations to ``class_::def()``, etc). This
1259+
before any binding code (e.g. invocations to ``class_::def()``, etc.). This
12591260
macro must be specified at the top level, since instantiates a partial template
12601261
overload. If your binding code consists of multiple compilation units, it must
12611262
be present in every file preceding any usage of ``std::vector<int>``. Opaque

0 commit comments

Comments
 (0)