[Numpy-discussion] Add pybind11 to docs about writing binding code

Sylvain Corlay sylvain.corlay at gmail.com
Wed Aug 15 13:38:18 EDT 2018


Hi Hans, Pauli,

If `pybind11` is included, it could be interesting to also include
`xtensor` and `xtensor-python`.

 - Xtensor is a C++ dynamic N-d array library that offers numpy-like
features including broadcasting and universal functions. It is also lazy
evaluated and continuously benchmarked against numpy, eigen, pythran and
numba. You can check out the numpy to xtensor cheat sheet:
https://xtensor.readthedocs.io/en/latest/numpy.html.

 - Xtensor-python makes it possible to operate on numpy arrays inplace
using the xtensor API. So that e.g. an xtensor reshape will result in a
reshape on the python side (using the numpy C API under the hood).

Xtensor-python is built upon pybind11, but brings it much closer to feature
parity with NumPy. There is a vibrant community of users and developers,
actively working to make xtensor faster and cover more of numpy APIs.

I would argue that xtensor-python is one of the easiest ways to make use of
numpy arrays from a C++ program, given the similar high level API, and
tools to make ufuncs and bindings with one-liners.

Resources:

- xtensor: https://github.com/QuantStack/xtensor (documentation:
https://xtensor.readthedocs.io/)
- xtensor-python: https://github.com/QuantStack/xtensor-python
(documentation: https://xtensor-python.readthedocs.io/)
- xtensor-blas:  https://github.com/QuantStack/xtensor-blas (documentation:
https://xtensor-blas.readthedocs.io)
- xtensor-io: https://github.com/QuantStack/xtensor-io (documentation:
https://xtensor-io.readthedocs.io) for reading and writing various file
formats

Other language bindings:

- xtensor-julia: https://github.com/QuantStack/xtensor-julia
(documentation: https://xtensor-julia.readthedocs.io/en/latest/)
- xtensor-r: https://github.com/QuantStack/xtensor-r (documentation:
https://xtensor-r.readthedocs.io/en/latest/)

Best,

Sylvain


On Wed, Aug 15, 2018 at 12:50 PM, Pauli Virtanen <pav at iki.fi> wrote:

> Hi,
>
> ke, 2018-08-15 kello 11:40 +0200, Hans Dembinski kirjoitti:
> [clip: pybind11]
> > So far all these reasons and more, it should be mentioned and even
> > highlighted here:
> >
> > https://docs.scipy.org/doc/numpy/user/c-info.python-as-glue.html <
> > https://docs.scipy.org/doc/numpy/user/c-info.python-as-glue.html>
> >
> > I am happy to write a section about it. Disclaimer: I am not at all
> > affiliated with the pybind11 developers, just a thankful user.
>
> Please go ahead --- the relevant source file is here:
>
> https://github.com/numpy/numpy/blob/master/doc/source/
> user/c-info.python-as-glue.rst
>
> It also does no mention CFFI either, mostly because the original text
> predates the project.
>
> --
> Pauli Virtanen
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180815/2e36c1b1/attachment.html>


More information about the NumPy-Discussion mailing list