From 3e0446e7fda10c3d85a628b8c1effaa5bf7f5529 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Mon, 14 Mar 2005 04:58:13 +0000 Subject: fixes for OSX docs optimizations and fixes use optimized version optimized function calls adjust pd and py files for correct argument passing more optimizations svn path=/trunk/; revision=2627 --- externals/grill/py/source/main.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'externals/grill/py/source/main.cpp') diff --git a/externals/grill/py/source/main.cpp b/externals/grill/py/source/main.cpp index aa234cc4..252d3408 100644 --- a/externals/grill/py/source/main.cpp +++ b/externals/grill/py/source/main.cpp @@ -24,8 +24,8 @@ static PyObject *gcollect = NULL; typedef std::map PyThrMap; static PyInterpreterState *pymain = NULL; -static PyThreadState *pythrmain = NULL; static PyThrMap pythrmap; +PyThreadState *pybase::pythrsys = NULL; int pybase::lockcount = 0; @@ -62,8 +62,6 @@ void pybase::FreeThreadState() PyObject *pybase::module_obj = NULL; PyObject *pybase::module_dict = NULL; -PyObject *pybase::emptytuple = NULL; - void initsymbol(); void initsamplebuffer(); @@ -95,12 +93,12 @@ void pybase::lib_setup() PyEval_InitThreads(); // get thread state - pythrmain = PyThreadState_Get(); + pythrsys = PyThreadState_Get(); // get main interpreter state - pymain = pythrmain->interp; + pymain = pythrsys->interp; // add thread state of main thread to map - pythrmap[GetThreadId()] = pythrmain; + pythrmap[GetThreadId()] = pythrsys; #endif // sys.argv must be set to empty tuple @@ -143,8 +141,6 @@ void pybase::lib_setup() initsamplebuffer(); PyModule_AddObject(module_obj,"Buffer",(PyObject *)&pySamplebuffer_Type); - emptytuple = PyTuple_New(0); - // ------------------------------------------------------------- FLEXT_SETUP(pyobj); @@ -169,14 +165,14 @@ pybase::pybase() , shouldexit(false),thrcount(0),stoptick(0) #endif { - PyThreadState *state = PyLock(); + PyThreadState *state = PyLockSys(); Py_INCREF(module_obj); PyUnlock(state); } pybase::~pybase() { - PyThreadState *state = PyLock(); + PyThreadState *state = PyLockSys(); Py_XDECREF(module_obj); PyUnlock(state); } @@ -527,13 +523,13 @@ bool pybase::qucall(PyObject *fun,PyObject *args) void pybase::threadworker() { FifoEl *el; - PyThreadState *state; + PyThreadState *my = FindThreadState(),*state; ++thrcount; for(;;) { while(el = qufifo.Get()) { ++thrcount; - state = PyLock(); + state = PyLock(my); callpy(el->fun,el->args); Py_XDECREF(el->fun); Py_XDECREF(el->args); @@ -547,7 +543,7 @@ void pybase::threadworker() qucond.Wait(); } - state = PyLock(); + state = PyLock(my); // unref remaining Python objects while(el = qufifo.Get()) { Py_XDECREF(el->fun); @@ -575,9 +571,7 @@ short pybase::patcher_myvol(t_patcher *x) bool pybase::collect() { if(gcollect) { - Py_INCREF(emptytuple); - PyObject *ret = PyObject_Call(gcollect,emptytuple,NULL); - Py_DECREF(emptytuple); + PyObject *ret = PyObject_CallObject(gcollect,NULL); if(ret) { #ifdef FLEXT_DEBUG int refs = PyInt_AsLong(ret); -- cgit v1.2.1