summaryrefslogtreecommitdiff
path: root/python/pyinterp.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-01-24 01:46:59 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-01-24 01:46:59 -0400
commitdff450ab3dbcb0819029c0bd5aee8dd78703a864 (patch)
treef3202de92fc80753c1189eadbe9f912e5cb2298c /python/pyinterp.h
parent876e2a906498c527cc2e447394bcdd6567dbd5be (diff)
downloadledger-dff450ab3dbcb0819029c0bd5aee8dd78703a864.tar.gz
ledger-dff450ab3dbcb0819029c0bd5aee8dd78703a864.tar.bz2
ledger-dff450ab3dbcb0819029c0bd5aee8dd78703a864.zip
Only initialize Python if it's used.
Diffstat (limited to 'python/pyinterp.h')
-rw-r--r--python/pyinterp.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/python/pyinterp.h b/python/pyinterp.h
index cf9ee486..df0e00dd 100644
--- a/python/pyinterp.h
+++ b/python/pyinterp.h
@@ -44,15 +44,22 @@ class python_interpreter_t : public session_t
{
public:
boost::python::dict main_nspace;
+ bool is_initialized;
- python_interpreter_t();
-
+ python_interpreter_t()
+ : session_t(), main_nspace(), is_initialized(false) {
+ TRACE_CTOR(python_interpreter_t, "");
+ }
+
virtual ~python_interpreter_t() {
TRACE_DTOR(python_interpreter_t);
- Py_Finalize();
+ if (is_initialized)
+ Py_Finalize();
}
+ void initialize();
+
boost::python::object import(const string& name);
enum py_eval_mode_t {