Skip to content

Instantly share code, notes, and snippets.

@unbit
Created February 25, 2014 11:52
Show Gist options
  • Save unbit/9207516 to your computer and use it in GitHub Desktop.
Save unbit/9207516 to your computer and use it in GitHub Desktop.
Embedding PyPy in C/C++
call rpython_startup_code(); for initializing
call pypy_setup_home(char *home, int debug); for setting the python home (returns non-zero on error, you can call it multiple times until it succeed)
call pypy_execute_source(char *code); execute the python code (IMPORTANT: GIL is still not set here)
call pypy_init_threads(); initialize GIL
finally call pypy_thread_attach(); in each additional pthread you need to register to python (this function is not thread safe, you should call it under a mutex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment