Skip to content

CPython Integration

brett hartshorn edited this page Mar 14, 2015 · 14 revisions

CPython

links your final executeable to libpython.

Syntax

-> is special syntax for PyObjects that is used inplace of the normal dot . operator. Below calls somemethod on pyob.

pyob->somemethod()

All code that interacts with the PythonVM needs to be blocked inside a with gil: block.

with gil:
   pyob->method()

Conversion back to C++ native types. Below would convert the result of method to an int.

a = pyob->method() as int

https://github.com/rusthon/Rusthon/blob/master/examples/cpython_embed.md

https://github.com/rusthon/Rusthon/blob/master/examples/cpython_multithreaded.md

Sidebar

Clone this wiki locally