pybind11/docs/advanced
Jason Rhinelander 423a49b8be array: add unchecked access via proxy object
This adds bounds-unchecked access to arrays through a `a.unchecked<Type,
Dimensions>()` method.  (For `array_t<T>`, the `Type` template parameter
is omitted).  The mutable version (which requires the array have the
`writeable` flag) is available as `a.mutable_unchecked<...>()`.

Specifying the Dimensions as a template parameter allows storage of an
std::array; having the strides and sizes stored that way (as opposed to
storing a copy of the array's strides/shape pointers) allows the
compiler to make significant optimizations of the shape() method that it
can't make with a pointer; testing with nested loops of the form:

    for (size_t i0 = 0; i0 < r.shape(0); i0++)
        for (size_t i1 = 0; i1 < r.shape(1); i1++)
            ...
                r(i0, i1, ...) += 1;

over a 10 million element array gives around a 25% speedup (versus using
a pointer) for the 1D case, 33% for 2D, and runs more than twice as fast
with a 5D array.
2017-03-22 16:13:59 -03:00
..
cast Eigen<->numpy referencing support 2017-02-24 23:19:50 +01:00
pycpp array: add unchecked access via proxy object 2017-03-22 16:13:59 -03:00
classes.rst Enable static properties (py::metaclass) by default 2017-02-23 15:45:26 +01:00
exceptions.rst Reorganize documentation 2016-10-20 15:21:34 +02:00
functions.rst Eigen<->numpy referencing support 2017-02-24 23:19:50 +01:00
misc.rst Documentation: explicitly call out that the GIL is held (#615) 2017-01-31 17:06:13 +01:00
smart_ptrs.rst Improve custom holder support (#607) 2017-01-31 17:05:44 +01:00