Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
PyPI

pybind11 3.0.0

pip install pybind11

Latest version

Released:

Seamless operability between C++11 and Python

Verified details

These details have beenverified by PyPI
Project links
GitHub Statistics
Maintainers
Avatar for henryiii from gravatar.comhenryiiiAvatar for wjakob from gravatar.comwjakob

Unverified details

These details havenot been verified by PyPI
Project links
Meta

Project description

pybind11 logo

pybind11 (v3) — Seamless interoperability between C++ and Python

Latest Documentation StatusStable Documentation StatusGitter chatGitHub Discussions

CIBuild statusSPEC 4 — Using and Creating Nightly Wheels

RepologyPyPI packageConda-forgePython Versions

Setuptools exampleScikit-build exampleCMake example

pybind11 is a lightweight header-only library that exposes C++ typesin Python and vice versa, mainly to create Python bindings of existingC++ code. Its goals and syntax are similar to the excellentBoost.Pythonlibrary by David Abrahams: to minimize boilerplate code in traditionalextension modules by inferring type information using compile-timeintrospection.

The main issue with Boost.Python—and the reason for creating such asimilar project—is Boost. Boost is an enormously large and complex suiteof utility libraries that works with almost every C++ compiler inexistence. This compatibility has its cost: arcane template tricks andworkarounds are necessary to support the oldest and buggiest of compilerspecimens. Now that C++11-compatible compilers are widely available,this heavy machinery has become an excessively large and unnecessarydependency.

Think of this library as a tiny self-contained version of Boost.Pythonwith everything stripped away that isn’t relevant for bindinggeneration. Without comments, the core header files only require ~4Klines of code and depend on Python (CPython 3.8+, PyPy, or GraalPy) and the C++standard library. This compact implementation was possible thanks to some C++11language features (specifically: tuples, lambda functions and variadictemplates). Since its creation, this library has grown beyond Boost.Python inmany ways, leading to dramatically simpler binding code in many commonsituations.

Tutorial and reference documentation is provided atpybind11.readthedocs.io.A PDF version of the manual is availablehere.And the source code is always available atgithub.com/pybind/pybind11.

Core features

pybind11 can map the following core C++ features 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

  • Arbitrary exception types

  • Enumerations

  • Callbacks

  • Iterators and ranges

  • Custom operators

  • Single and multiple inheritance

  • STL data structures

  • Smart pointers with reference counting likestd::shared_ptr

  • Internal references with correct reference counting

  • C++ classes with virtual (and pure virtual) methods can be extendedin Python

  • Integrated NumPy support (NumPy 2 requires pybind11 2.12+)

Goodies

In addition to the core functionality, pybind11 provides some extragoodies:

  • CPython 3.8+, PyPy3 7.3.17+, and GraalPy 24.1+ are supported with animplementation-agnostic interface (see older versions for older CPythonand PyPy versions).

  • It is possible to bind C++11 lambda functions with capturedvariables. The lambda capture data is stored inside the resultingPython function object.

  • pybind11 uses C++11 move constructors and move assignment operatorswhenever possible to efficiently transfer custom data types.

  • It’s easy to expose the internal storage of custom data types throughPythons’ buffer protocols. This is handy e.g. for fast conversionbetween C++ matrix classes like Eigen and NumPy without expensivecopy operations.

  • pybind11 can automatically vectorize functions so that they aretransparently applied to all entries of one or more NumPy arrayarguments.

  • Python’s slice-based access and assignment operations can besupported with just a few lines of code.

  • Everything is contained in just a few header files; there is no needto link against any additional libraries.

  • Binaries are generally smaller by a factor of at least 2 compared toequivalent bindings generated by Boost.Python. A recent pybind11conversion of PyRosetta, an enormous Boost.Python binding project,reporteda binary size reduction of5.4x and compile time reduction by5.8x.

  • Function signatures are precomputed at compile time (usingconstexpr), leading to smaller binaries.

  • With little extra effort, C++ types can be pickled and unpickledsimilar to regular Python objects.

Supported compilers

  1. Clang/LLVM 3.3 or newer (for Apple Xcode’s clang, this is 5.0.0 ornewer)

  2. GCC 4.8 or newer

  3. Microsoft Visual Studio 2022 or newer (2019 probably works, but was dropped in CI)

  4. Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI)

  5. Cygwin/GCC (previously tested on 2.5.1)

  6. NVCC (CUDA 11.0 tested in CI)

  7. NVIDIA PGI (20.9 tested in CI)

Supported Platforms

  • Windows, Linux, macOS, and iOS

  • CPython 3.8+, Pyodide, PyPy, and GraalPy

  • C++11, C++14, C++17, C++20, and C++23

About

This project was created byWenzelJakob. Significant features and/orimprovements to the code were contributed byJonas Adler,Lori A. Burns,Sylvain Corlay,Eric Cousineau,Aaron Gokaslan,Ralf Grosse-Kunstleve,Trent Houliston,Axel Huebl,@hulucc,Yannick Jadoul,Sergey Lyskov,Johan Mabille,Tomasz Miąsko,Dean Moldovan,Ben Pritchard,Jason Rhinelander,Boris Schäling,Pim Schellart,Henry Schreiner,Ivan Smirnov,Dustin Spicuzza,Boris Staletic,Ethan Steinberg,Patrick Stewart,Ivor Wanders,andXiaofei Wang.

We thank Google for a generous financial contribution to the continuousintegration infrastructure used by this project.

Contributing

See thecontributingguidefor information on building and contributing to pybind11.

License

pybind11 is provided under a BSD-style license that can be found in theLICENSEfile. By using, distributing, or contributing to this project, you agreeto the terms and conditions of this license.

Project details

Verified details

These details have beenverified by PyPI
Project links
GitHub Statistics
Maintainers
Avatar for henryiii from gravatar.comhenryiiiAvatar for wjakob from gravatar.comwjakob

Unverified details

These details havenot been verified by PyPI
Project links
Meta

Release historyRelease notifications |RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more aboutinstalling packages.

Source Distribution

pybind11-3.0.0.tar.gz (544.8 kBview details)

UploadedSource

Built Distribution

pybind11-3.0.0-py3-none-any.whl (292.1 kBview details)

UploadedPython 3

File details

Details for the filepybind11-3.0.0.tar.gz.

File metadata

  • Download URL:pybind11-3.0.0.tar.gz
  • Upload date:
  • Size: 544.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pybind11-3.0.0.tar.gz
AlgorithmHash digest
SHA256c3f07bce3ada51c3e4b76badfa85df11688d12c46111f9d242bc5c9415af7862
MD5bc52c29827256a290bfa7b27e589b75f
BLAKE2b-256ef83698d120e257a116f2472c710932023ad779409adf2734d2e940f34eea2c5

See more details on using hashes here.

Provenance

The following attestation bundles were made forpybind11-3.0.0.tar.gz:

Publisher:pip.yml on pybind/pybind11

Attestations:Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the filepybind11-3.0.0-py3-none-any.whl.

File metadata

  • Download URL:pybind11-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 292.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pybind11-3.0.0-py3-none-any.whl
AlgorithmHash digest
SHA2567c5cac504da5a701b5163f0e6a7ba736c713a096a5378383c5b4b064b753f607
MD5a83ea63562a755b0b02373f0dd052e56
BLAKE2b-256419c85f50a5476832c3efc67b6d7997808388236ae4754bf53e1749b3bc27577

See more details on using hashes here.

Provenance

The following attestation bundles were made forpybind11-3.0.0-py3-none-any.whl:

Publisher:pip.yml on pybind/pybind11

Attestations:Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security SponsorDatadog MonitoringFastly CDNGoogle Download AnalyticsPingdom MonitoringSentry Error loggingStatusPage Status page

[8]ページ先頭

©2009-2025 Movatter.jp