intro.rst (11986:c12e4625ab56) intro.rst (12037:d28054ac6ec9)
1.. image:: pybind11-logo.png
2
3About this project
4==================
5**pybind11** is a lightweight header-only library that exposes C++ types in Python
6and vice versa, mainly to create Python bindings of existing C++ code. Its
7goals and syntax are similar to the excellent `Boost.Python`_ library by David
8Abrahams: to minimize boilerplate code in traditional extension modules by
9inferring type information using compile-time introspection.
10
11.. _Boost.Python: http://www.boost.org/doc/libs/release/libs/python/doc/index.html
12
13The main issue with Boost.Python—and the reason for creating such a similar
14project—is Boost. Boost is an enormously large and complex suite of utility
15libraries that works with almost every C++ compiler in existence. This
16compatibility has its cost: arcane template tricks and workarounds are
17necessary to support the oldest and buggiest of compiler specimens. Now that
18C++11-compatible compilers are widely available, this heavy machinery has
19become an excessively large and unnecessary dependency.
1.. image:: pybind11-logo.png
2
3About this project
4==================
5**pybind11** is a lightweight header-only library that exposes C++ types in Python
6and vice versa, mainly to create Python bindings of existing C++ code. Its
7goals and syntax are similar to the excellent `Boost.Python`_ library by David
8Abrahams: to minimize boilerplate code in traditional extension modules by
9inferring type information using compile-time introspection.
10
11.. _Boost.Python: http://www.boost.org/doc/libs/release/libs/python/doc/index.html
12
13The main issue with Boost.Python—and the reason for creating such a similar
14project—is Boost. Boost is an enormously large and complex suite of utility
15libraries that works with almost every C++ compiler in existence. This
16compatibility has its cost: arcane template tricks and workarounds are
17necessary to support the oldest and buggiest of compiler specimens. Now that
18C++11-compatible compilers are widely available, this heavy machinery has
19become an excessively large and unnecessary dependency.
20
21Think of this library as a tiny self-contained version of Boost.Python with
22everything stripped away that isn't relevant for binding generation. Without
20Think of this library as a tiny self-contained version of Boost.Python with
21everything stripped away that isn't relevant for binding generation. Without
23comments, the core header files only require ~2.5K lines of code and depend on
24Python (2.7 or 3.x) and the C++ standard library. This compact implementation
25was possible thanks to some of the new C++11 language features (specifically:
26tuples, lambda functions and variadic templates). Since its creation, this
27library has grown beyond Boost.Python in many ways, leading to dramatically
28simpler binding code in many common situations.
22comments, the core header files only require ~4K lines of code and depend on
23Python (2.7 or 3.x, or PyPy2.7 >= 5.7) and the C++ standard library. This
24compact implementation was possible thanks to some of the new C++11 language
25features (specifically: tuples, lambda functions and variadic templates). Since
26its creation, this library has grown beyond Boost.Python in many ways, leading
27to dramatically simpler binding code in many common situations.
29
30Core features
31*************
32The following core C++ features can be mapped to Python
33
34- Functions accepting and returning custom data structures per value, reference, or pointer
35- Instance methods and static methods
36- Overloaded functions

--- 9 unchanged lines hidden (view full) ---

46- Smart pointers with reference counting like ``std::shared_ptr``
47- Internal references with correct reference counting
48- C++ classes with virtual (and pure virtual) methods can be extended in Python
49
50Goodies
51*******
52In addition to the core functionality, pybind11 provides some extra goodies:
53
28
29Core features
30*************
31The following core C++ features can be mapped to Python
32
33- Functions accepting and returning custom data structures per value, reference, or pointer
34- Instance methods and static methods
35- Overloaded functions

--- 9 unchanged lines hidden (view full) ---

45- Smart pointers with reference counting like ``std::shared_ptr``
46- Internal references with correct reference counting
47- C++ classes with virtual (and pure virtual) methods can be extended in Python
48
49Goodies
50*******
51In addition to the core functionality, pybind11 provides some extra goodies:
52
53- Python 2.7, 3.x, and PyPy (PyPy2.7 >= 5.7) are supported with an
54 implementation-agnostic interface.
55
54- It is possible to bind C++11 lambda functions with captured variables. The
55 lambda capture data is stored inside the resulting Python function object.
56
57- pybind11 uses C++11 move constructors and move assignment operators whenever
58 possible to efficiently transfer custom data types.
59
60- It's easy to expose the internal storage of custom data types through
61 Pythons' buffer protocols. This is handy e.g. for fast conversion between

--- 21 unchanged lines hidden (view full) ---

83 regular Python objects.
84
85.. _PyRosetta: http://graylab.jhu.edu/RosettaCon2016/PyRosetta-4.pdf
86
87Supported compilers
88*******************
89
901. Clang/LLVM (any non-ancient version with C++11 support)
56- It is possible to bind C++11 lambda functions with captured variables. The
57 lambda capture data is stored inside the resulting Python function object.
58
59- pybind11 uses C++11 move constructors and move assignment operators whenever
60 possible to efficiently transfer custom data types.
61
62- It's easy to expose the internal storage of custom data types through
63 Pythons' buffer protocols. This is handy e.g. for fast conversion between

--- 21 unchanged lines hidden (view full) ---

85 regular Python objects.
86
87.. _PyRosetta: http://graylab.jhu.edu/RosettaCon2016/PyRosetta-4.pdf
88
89Supported compilers
90*******************
91
921. Clang/LLVM (any non-ancient version with C++11 support)
912. GCC (any non-ancient version with C++11 support)
932. GCC 4.8 or newer
923. Microsoft Visual Studio 2015 or newer
934. Intel C++ compiler v15 or newer
943. Microsoft Visual Studio 2015 or newer
954. Intel C++ compiler v15 or newer