pybind11/example/example11.py
Wenzel Jakob 66c9a40213 Much more efficient generation of function signatures, updated docs
This modification taps into some newer C++14 features (if present) to
generate function signatures considerably more efficiently at compile
time rather than at run time.

With this change, pybind11 binaries are now *2.1 times* smaller compared
to the Boost.Python baseline in the benchmark. Compilation times get a
nice improvement as well.

Visual Studio 2015 unfortunately doesn't implement 'constexpr' well
enough yet to support this change and uses a runtime fallback.
2016-01-17 22:31:15 +01:00

32 lines
552 B
Python
Executable File

#!/usr/bin/env python
from __future__ import print_function
import sys
import pydoc
sys.path.append('.')
from example import kw_func, kw_func2, kw_func3
print(pydoc.render_doc(kw_func, "Help on %s"))
print(pydoc.render_doc(kw_func2, "Help on %s"))
print(pydoc.render_doc(kw_func3, "Help on %s"))
kw_func(5, 10)
kw_func(5, y=10)
kw_func(y=10, x=5)
kw_func2()
kw_func2(5)
kw_func2(x=5)
kw_func2(y=10)
kw_func2(5, 10)
kw_func2(x=5, y=10)
try:
kw_func2(x=5, y=10, z=12)
except Exception as e:
print("Caught expected exception: " + str(e))