8
8
[ ![ CI] ( https://github.com/pybind/pybind11/workflows/CI/badge.svg )] ( https://github.com/pybind/pybind11/actions )
9
9
[ ![ Build status] ( https://ci.appveyor.com/api/projects/status/riaj54pn4h08xy40?svg=true )] ( https://ci.appveyor.com/project/wjakob/pybind11 )
10
10
11
- ** pybind11** is a lightweight header-only library that exposes C++ types in Python
12
- and vice versa, mainly to create Python bindings of existing C++ code. Its
13
- goals and syntax are similar to the excellent
14
- [ Boost.Python] ( http://www.boost.org/doc/libs/1_58_0/libs/python/doc/ ) library
15
- by David Abrahams: to minimize boilerplate code in traditional extension
16
- modules by inferring type information using compile-time introspection.
11
+ ** pybind11** is a lightweight header-only library that exposes C++ types in
12
+ Python and vice versa, mainly to create Python bindings of existing C++ code.
13
+ Its goals and syntax are similar to the excellent [ Boost.Python] [ ] library by
14
+ David Abrahams: to minimize boilerplate code in traditional extension modules
15
+ by inferring type information using compile-time introspection.
17
16
18
17
The main issue with Boost.Python—and the reason for creating such a similar
19
18
project—is Boost. Boost is an enormously large and complex suite of utility
@@ -26,19 +25,18 @@ become an excessively large and unnecessary dependency.
26
25
Think of this library as a tiny self-contained version of Boost.Python with
27
26
everything stripped away that isn't relevant for binding generation. Without
28
27
comments, the core header files only require ~ 4K lines of code and depend on
29
- Python (2.7 or 3.x , or PyPy2.7 >= 5.7 ) and the C++ standard library. This
30
- compact implementation was possible thanks to some of the new C++11 language
31
- features (specifically: tuples, lambda functions and variadic templates). Since
32
- its creation, this library has grown beyond Boost.Python in many ways, leading
33
- to dramatically simpler binding code in many common situations.
28
+ Python (2.7 or 3.5+ , or PyPy ) and the C++ standard library. This compact
29
+ implementation was possible thanks to some of the new C++11 language features
30
+ (specifically: tuples, lambda functions and variadic templates). Since its
31
+ creation, this library has grown beyond Boost.Python in many ways, leading to
32
+ dramatically simpler binding code in many common situations.
34
33
35
34
Tutorial and reference documentation is provided at
36
- [ http://pybind11.readthedocs.org/en/master ] ( http://pybind11.readthedocs.org/en/master ) .
37
- A PDF version of the manual is available
38
- [ here] ( https://media.readthedocs.org/pdf/pybind11/master/pybind11.pdf ) .
35
+ [ pybind11.readthedocs.org] [ ] . A PDF version of the manual is available
36
+ [ here] [ docs-pdf ] .
39
37
40
38
## Core features
41
- pybind11 can map the following core C++ features to Python
39
+ pybind11 can map the following core C++ features to Python:
42
40
43
41
- Functions accepting and returning custom data structures per value, reference, or pointer
44
42
- Instance methods and static methods
@@ -51,15 +49,15 @@ pybind11 can map the following core C++ features to Python
51
49
- Custom operators
52
50
- Single and multiple inheritance
53
51
- STL data structures
54
- - Smart pointers with reference counting like `` std::shared_ptr ` `
52
+ - Smart pointers with reference counting like ` std::shared_ptr `
55
53
- Internal references with correct reference counting
56
54
- C++ classes with virtual (and pure virtual) methods can be extended in Python
57
55
58
56
## Goodies
59
57
In addition to the core functionality, pybind11 provides some extra goodies:
60
58
61
- - Python 2.7, 3.x , and PyPy (PyPy2.7 >= 5.7 ) are supported with an
62
- implementation-agnostic interface.
59
+ - Python 2.7, 3.5+ , and PyPy (tested on 7.3 ) are supported with an implementation-agnostic
60
+ interface.
63
61
64
62
- It is possible to bind C++11 lambda functions with captured variables. The
65
63
lambda capture data is stored inside the resulting Python function object.
@@ -83,10 +81,10 @@ In addition to the core functionality, pybind11 provides some extra goodies:
83
81
- Binaries are generally smaller by a factor of at least 2 compared to
84
82
equivalent bindings generated by Boost.Python. A recent pybind11 conversion
85
83
of PyRosetta, an enormous Boost.Python binding project,
86
- [ reported] ( http://graylab.jhu.edu/RosettaCon2016/PyRosetta-4.pdf ) a binary
87
- size reduction of ** 5.4x ** and compile time reduction by ** 5.8x** .
84
+ [ reported] [ pyrosetta-report ] a binary size reduction of ** 5.4x ** and compile
85
+ time reduction by ** 5.8x** .
88
86
89
- - Function signatures are precomputed at compile time (using `` constexpr ` ` ),
87
+ - Function signatures are precomputed at compile time (using ` constexpr ` ),
90
88
leading to smaller binaries.
91
89
92
90
- With little extra effort, C++ types can be pickled and unpickled similar to
@@ -97,7 +95,8 @@ In addition to the core functionality, pybind11 provides some extra goodies:
97
95
1 . Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or newer)
98
96
2 . GCC 4.8 or newer
99
97
3 . Microsoft Visual Studio 2015 Update 3 or newer
100
- 4 . Intel C++ compiler 17 or newer (16 with pybind11 v2.0 and 15 with pybind11 v2.0 and a [ workaround] ( https://github.com/pybind/pybind11/issues/276 ) )
98
+ 4 . Intel C++ compiler 17 or newer (16 with pybind11 v2.0 and 15 with pybind11
99
+ v2.0 and a [ workaround] [ intel-15-workaround ] )
101
100
5 . Cygwin/GCC (tested on 2.5.1)
102
101
103
102
## About
@@ -122,8 +121,23 @@ Henry Schreiner,
122
121
Ivan Smirnov, and
123
122
Patrick Stewart.
124
123
124
+ ### Contributing
125
+
126
+ See the [ contributing guide] [ ] for information on building and contributing to
127
+ pybind11.
128
+
129
+
125
130
### License
126
131
127
132
pybind11 is provided under a BSD-style license that can be found in the
128
- `` LICENSE `` file. By using, distributing, or contributing to this project,
133
+ [ ` LICENSE ` ] [ ] file. By using, distributing, or contributing to this project,
129
134
you agree to the terms and conditions of this license.
135
+
136
+
137
+ [ pybind11.readthedocs.org ] : http://pybind11.readthedocs.org/en/master
138
+ [ docs-pdf ] : https://media.readthedocs.org/pdf/pybind11/master/pybind11.pdf
139
+ [ Boost.Python ] : http://www.boost.org/doc/libs/1_58_0/libs/python/doc/
140
+ [ pyrosetta-report ] : http://graylab.jhu.edu/RosettaCon2016/PyRosetta-4.pdf
141
+ [ contributing guide ] : https://github.com/pybind/pybind11/blob/master/CONTRIBUTING.md
142
+ [ `LICENSE` ] : https://github.com/pybind/pybind11/blob/master/LICENSE
143
+ [ intel-15-workaround ] : https://github.com/pybind/pybind11/issues/276
0 commit comments