mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-21 20:55:11 +00:00
423a49b8be
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. |
||
---|---|---|
.. | ||
_static | ||
advanced | ||
basics.rst | ||
benchmark.py | ||
benchmark.rst | ||
changelog.rst | ||
classes.rst | ||
compiling.rst | ||
conf.py | ||
Doxyfile | ||
faq.rst | ||
index.rst | ||
intro.rst | ||
limitations.rst | ||
Makefile | ||
pybind11_vs_boost_python1.png | ||
pybind11_vs_boost_python1.svg | ||
pybind11_vs_boost_python2.png | ||
pybind11_vs_boost_python2.svg | ||
pybind11-logo.png | ||
reference.rst | ||
release.rst | ||
requirements.txt |