Python C++ interface¶

pybind11 exposes Python types and functions using thin C++ wrappers, which makes it possible to conveniently call Python code from C++ without resorting to Python’s C API.

  • Python types
    • Available wrappers
    • Instantiating compound Python types from C++
    • Casting back and forth
    • Accessing Python libraries from C++
    • Calling Python functions
    • Calling Python methods
    • Keyword arguments
    • Unpacking arguments
    • Implicit casting
    • Handling exceptions
    • Gotchas
  • NumPy
    • Buffer protocol
    • Arrays
    • Structured types
    • Vectorizing functions
    • Direct access
    • Ellipsis
    • Memory view
  • Utilities
    • Using Python’s print function in C++
    • Capturing standard output from ostream
    • Evaluating Python expressions from strings and files

pybind11

Navigation

  • Changelog
  • Upgrade guide

The Basics

  • Installing the library
  • First steps
  • Object-oriented code
  • Build systems

Advanced Topics

  • Functions
  • Classes
  • Exceptions
  • Smart pointers
  • Type conversions
  • Python C++ interface
    • Python types
    • NumPy
    • Utilities
  • Embedding the interpreter
  • Miscellaneous

Extra Information

  • Frequently asked questions
  • Benchmark
  • Limitations
  • Reference
  • CMake helpers

Related Topics

  • Documentation overview
    • Previous: Custom type casters
    • Next: Python types

Quick search

©2023, Wenzel Jakob. | Powered by Sphinx 5.3.0 & Alabaster 0.7.12 | Page source