Back to home page

EIC code displayed by LXR

 
 

    


Warning, /jana2/src/python/externals/pybind11-2.10.3/README.rst is written in an unsupported language. File is not indexed.

0001 .. figure:: https://github.com/pybind/pybind11/raw/master/docs/pybind11-logo.png
0002    :alt: pybind11 logo
0003 
0004 **pybind11 — Seamless operability between C++11 and Python**
0005 
0006 |Latest Documentation Status| |Stable Documentation Status| |Gitter chat| |GitHub Discussions| |CI| |Build status|
0007 
0008 |Repology| |PyPI package| |Conda-forge| |Python Versions|
0009 
0010 `Setuptools example <https://github.com/pybind/python_example>`_
0011 • `Scikit-build example <https://github.com/pybind/scikit_build_example>`_
0012 • `CMake example <https://github.com/pybind/cmake_example>`_
0013 
0014 .. start
0015 
0016 
0017 **pybind11** is a lightweight header-only library that exposes C++ types
0018 in Python and vice versa, mainly to create Python bindings of existing
0019 C++ code. Its goals and syntax are similar to the excellent
0020 `Boost.Python <http://www.boost.org/doc/libs/1_58_0/libs/python/doc/>`_
0021 library by David Abrahams: to minimize boilerplate code in traditional
0022 extension modules by inferring type information using compile-time
0023 introspection.
0024 
0025 The main issue with Boost.Python—and the reason for creating such a
0026 similar project—is Boost. Boost is an enormously large and complex suite
0027 of utility libraries that works with almost every C++ compiler in
0028 existence. This compatibility has its cost: arcane template tricks and
0029 workarounds are necessary to support the oldest and buggiest of compiler
0030 specimens. Now that C++11-compatible compilers are widely available,
0031 this heavy machinery has become an excessively large and unnecessary
0032 dependency.
0033 
0034 Think of this library as a tiny self-contained version of Boost.Python
0035 with everything stripped away that isn't relevant for binding
0036 generation. Without comments, the core header files only require ~4K
0037 lines of code and depend on Python (3.6+, or PyPy) and the C++
0038 standard library. This compact implementation was possible thanks to
0039 some of the new C++11 language features (specifically: tuples, lambda
0040 functions and variadic templates). Since its creation, this library has
0041 grown beyond Boost.Python in many ways, leading to dramatically simpler
0042 binding code in many common situations.
0043 
0044 Tutorial and reference documentation is provided at
0045 `pybind11.readthedocs.io <https://pybind11.readthedocs.io/en/latest>`_.
0046 A PDF version of the manual is available
0047 `here <https://pybind11.readthedocs.io/_/downloads/en/latest/pdf/>`_.
0048 And the source code is always available at
0049 `github.com/pybind/pybind11 <https://github.com/pybind/pybind11>`_.
0050 
0051 
0052 Core features
0053 -------------
0054 
0055 
0056 pybind11 can map the following core C++ features to Python:
0057 
0058 - Functions accepting and returning custom data structures per value,
0059   reference, or pointer
0060 - Instance methods and static methods
0061 - Overloaded functions
0062 - Instance attributes and static attributes
0063 - Arbitrary exception types
0064 - Enumerations
0065 - Callbacks
0066 - Iterators and ranges
0067 - Custom operators
0068 - Single and multiple inheritance
0069 - STL data structures
0070 - Smart pointers with reference counting like ``std::shared_ptr``
0071 - Internal references with correct reference counting
0072 - C++ classes with virtual (and pure virtual) methods can be extended
0073   in Python
0074 
0075 Goodies
0076 -------
0077 
0078 In addition to the core functionality, pybind11 provides some extra
0079 goodies:
0080 
0081 - Python 3.6+, and PyPy3 7.3 are supported with an implementation-agnostic
0082   interface (pybind11 2.9 was the last version to support Python 2 and 3.5).
0083 
0084 - It is possible to bind C++11 lambda functions with captured
0085   variables. The lambda capture data is stored inside the resulting
0086   Python function object.
0087 
0088 - pybind11 uses C++11 move constructors and move assignment operators
0089   whenever possible to efficiently transfer custom data types.
0090 
0091 - It's easy to expose the internal storage of custom data types through
0092   Pythons' buffer protocols. This is handy e.g. for fast conversion
0093   between C++ matrix classes like Eigen and NumPy without expensive
0094   copy operations.
0095 
0096 - pybind11 can automatically vectorize functions so that they are
0097   transparently applied to all entries of one or more NumPy array
0098   arguments.
0099 
0100 - Python's slice-based access and assignment operations can be
0101   supported with just a few lines of code.
0102 
0103 - Everything is contained in just a few header files; there is no need
0104   to link against any additional libraries.
0105 
0106 - Binaries are generally smaller by a factor of at least 2 compared to
0107   equivalent bindings generated by Boost.Python. A recent pybind11
0108   conversion of PyRosetta, an enormous Boost.Python binding project,
0109   `reported <https://graylab.jhu.edu/Sergey/2016.RosettaCon/PyRosetta-4.pdf>`_
0110   a binary size reduction of **5.4x** and compile time reduction by
0111   **5.8x**.
0112 
0113 - Function signatures are precomputed at compile time (using
0114   ``constexpr``), leading to smaller binaries.
0115 
0116 - With little extra effort, C++ types can be pickled and unpickled
0117   similar to regular Python objects.
0118 
0119 Supported compilers
0120 -------------------
0121 
0122 1. Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or
0123    newer)
0124 2. GCC 4.8 or newer
0125 3. Microsoft Visual Studio 2017 or newer
0126 4. Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI)
0127 5. Cygwin/GCC (previously tested on 2.5.1)
0128 6. NVCC (CUDA 11.0 tested in CI)
0129 7. NVIDIA PGI (20.9 tested in CI)
0130 
0131 About
0132 -----
0133 
0134 This project was created by `Wenzel
0135 Jakob <http://rgl.epfl.ch/people/wjakob>`_. Significant features and/or
0136 improvements to the code were contributed by Jonas Adler, Lori A. Burns,
0137 Sylvain Corlay, Eric Cousineau, Aaron Gokaslan, Ralf Grosse-Kunstleve, Trent Houliston, Axel
0138 Huebl, @hulucc, Yannick Jadoul, Sergey Lyskov Johan Mabille, Tomasz Miąsko,
0139 Dean Moldovan, Ben Pritchard, Jason Rhinelander, Boris Schäling, Pim
0140 Schellart, Henry Schreiner, Ivan Smirnov, Boris Staletic, and Patrick Stewart.
0141 
0142 We thank Google for a generous financial contribution to the continuous
0143 integration infrastructure used by this project.
0144 
0145 
0146 Contributing
0147 ~~~~~~~~~~~~
0148 
0149 See the `contributing
0150 guide <https://github.com/pybind/pybind11/blob/master/.github/CONTRIBUTING.md>`_
0151 for information on building and contributing to pybind11.
0152 
0153 License
0154 ~~~~~~~
0155 
0156 pybind11 is provided under a BSD-style license that can be found in the
0157 `LICENSE <https://github.com/pybind/pybind11/blob/master/LICENSE>`_
0158 file. By using, distributing, or contributing to this project, you agree
0159 to the terms and conditions of this license.
0160 
0161 .. |Latest Documentation Status| image:: https://readthedocs.org/projects/pybind11/badge?version=latest
0162    :target: http://pybind11.readthedocs.org/en/latest
0163 .. |Stable Documentation Status| image:: https://img.shields.io/badge/docs-stable-blue.svg
0164    :target: http://pybind11.readthedocs.org/en/stable
0165 .. |Gitter chat| image:: https://img.shields.io/gitter/room/gitterHQ/gitter.svg
0166    :target: https://gitter.im/pybind/Lobby
0167 .. |CI| image:: https://github.com/pybind/pybind11/workflows/CI/badge.svg
0168    :target: https://github.com/pybind/pybind11/actions
0169 .. |Build status| image:: https://ci.appveyor.com/api/projects/status/riaj54pn4h08xy40?svg=true
0170    :target: https://ci.appveyor.com/project/wjakob/pybind11
0171 .. |PyPI package| image:: https://img.shields.io/pypi/v/pybind11.svg
0172    :target: https://pypi.org/project/pybind11/
0173 .. |Conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pybind11.svg
0174    :target: https://github.com/conda-forge/pybind11-feedstock
0175 .. |Repology| image:: https://repology.org/badge/latest-versions/python:pybind11.svg
0176    :target: https://repology.org/project/python:pybind11/versions
0177 .. |Python Versions| image:: https://img.shields.io/pypi/pyversions/pybind11.svg
0178    :target: https://pypi.org/project/pybind11/
0179 .. |GitHub Discussions| image:: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
0180    :target: https://github.com/pybind/pybind11/discussions