Questions tagged [pybind11]

pybind11 is a C++/Python package offering seamless operability between C++11 and Python, in the spirit of “boost::python” but without the heavy-duty Boost dependency.

pybind11 — Seamless operability between C++11 and Python.

The following core C++ features can be mapped to Python:

  • Functions accepting and returning custom data structures per value, reference, or pointer
  • Instance methods and static methods
  • Overloaded functions
  • Instance attributes and static attributes
  • Many more…

In addition to the core functionality, pybind11 provides some extra goodies:

  • Python 2.7, 3.x, and PyPy (PyPy2.7 >= 5.7) are supported with an implementation-agnostic interface.
  • It is possible to bind C++11 lambda functions with captured variables. The lambda capture data is stored inside the resulting Python function object.
  • pybind11 uses C++11 move constructors and move assignment operators whenever possible to efficiently transfer custom data types.
  • Still more…

Supported compilers:

  • Clang/LLVM (any non-ancient version with C++11 support)
  • GCC 4.8 or newer
  • Microsoft Visual Studio 2015 or newer
  • Intel C++ compiler v15 or newer

See documentation at https://pybind11.readthedocs.io/en/latest/index.html

1040 questions
-2
votes
2 answers

Cmake find_package not finding Pybind11, even with a hint?

I am trying to use Pybind11 in a Cmake project. I'm using Cmake 3.23.0-rc2. To include it, I can do the following: find_package(pybind11 REQUIRED) However, this does not work on my machine. So, I attempted to give find_package a hint as per the user…
Tyler Shellberg
  • 1,086
  • 11
  • 28
-2
votes
1 answer

Why does pybind fail for functions without arguments?

I have an overloaded constructor in C++ (default + other). My automatically generated pybind code looks like this: py::class_(m, "MyClass") .def( py::init<>(), py::kw_only() ) .def( …
thzu
  • 23
  • 1
  • 4
-2
votes
2 answers

Trouble with cmake when install pybind11

I am trying to get started with pybind11, following the documentation. I have installed pybind11 using pip. The location of the directory is: ~/anaconda3/lib/python3.6/site-packages/pybind11 The next step is to compile the test cases. According to…
-4
votes
1 answer

Why C++ is slower than Python to evaluate functions?

I've heard that C++ is much faster than Python and I test that using pybind11. I created two analogous classes, one in C++ (Foo) and one in Python (Bar). I then use pybind11 to use C++ class in Python. The main idea of the class is that it should…
1 2 3
69
70