[docs] Py_SetPythonHome() before Py_Initialize()

Cody Smith cody at google.com
Thu Jan 5 03:02:57 CET 2012

Python folks,

Your "Initialization, Finalization, and Threads" document* explains
that embedded Python applications must call Py_Initialize() before any
other Python/C API functions, with a handful of exceptions.  It seems
like Py_SetPythonHome() should be among the exceptions, but it isn't.

Initialization potentially relies on "home", so Py_SetPythonHome() is
useful before Py_Initialize().  This situation is similar to
Py_SetProgramName(), which _is_ permitted before Py_Initialize().
Also, in practice, the implementation of Py_SetPythonHome() only
accesses a single static global variable, "default_home".  (This is
based on a spot check of 2.0.1, 2.6.7 and 3.2 branches).

Clarification would be much appreciated, since it might help me avoid
a hack.  Thanks,


* = http://docs.python.org/c-api/init.html

More information about the docs mailing list