diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2007-03-07 13:40:14 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2007-03-07 13:40:14 +0000 |
commit | 03c7468fcc51888c8271b904e4d6400ed5c1cbb1 (patch) | |
tree | 411627e2da0f574bba30fb6d6a5b772bff07e448 /externals/grill/py/source/pyatom.cpp | |
parent | 2f2aaa03a0ace959c6ff911d8b11b45f143c7d6e (diff) |
multiply inlets for py (hot and cold inlets)
small optimizations and fixes
use PyGILState_\*() functionality (enabled with PY_USE_GIL)
updates for DSP processing
__str__ method for pyext, to enable print self calls
added message bundle functionality (pyext.Bundle class)
enable compiled-only scripts (without .py)
enable optimization of Python code in reease build
let _inlets and _outlets default to 0
fix for numpy
some ASSERTs for explicitly created pyext classes (should be runtime checks i guess)
open editor for script under OS X
fixing numpy initialization quirks
enable symbol binding for all callables (not only functions and methods)
_isthreaded is now a data member instead of a method
fix for gcc4
added pyext._list and pyext._tuple to convert input lists to Python sequence objects
enable module packages (module/__init__.py[co]), now also for Max
python-like dotted module.function syntax
cleaned up float vs. int pyext tags
compiler flag to exclude DSP objects
some optimizations and py reload fix
more safety for calls where association python-pd has already been removed
always run Python interpreter in the background
svn path=/trunk/; revision=7474
Diffstat (limited to 'externals/grill/py/source/pyatom.cpp')
-rw-r--r-- | externals/grill/py/source/pyatom.cpp | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/externals/grill/py/source/pyatom.cpp b/externals/grill/py/source/pyatom.cpp index 07712f30..0af1b5e0 100644 --- a/externals/grill/py/source/pyatom.cpp +++ b/externals/grill/py/source/pyatom.cpp @@ -1,61 +1,61 @@ -/*
-
-py/pyext - python script object for PD and Max/MSP
-
-Copyright (c)2002-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-
-*/
-
-#include "pyatom.h"
-#include <map>
-
-#define INTV 0.01
-
-typedef std::map<size_t,PyObject *> ObjMap;
-
-static ObjMap objmap;
-static size_t collix = 0,curix = 0;
-static double last = 0;
-
-size_t PyAtom::Register(PyObject *obj)
-{
- Collect();
-
- Py_INCREF(obj);
- objmap[++curix] = obj;
-
-#ifdef _DEBUG
-// post("REG %p (%i)\n",obj,objmap.size());
-#endif
- return curix;
-}
-
-PyObject *PyAtom::Retrieve(size_t id)
-{
- ObjMap::iterator it = objmap.find(id);
- PyObject *ret = it == objmap.end()?NULL:it->second;
- Collect();
- return ret;
-}
-
-void PyAtom::Collect()
-{
- for(;;) {
- ObjMap::iterator it = objmap.begin();
- if(it == objmap.end() || it->first > collix) break;
-
- PyObject *obj = it->second;
- Py_DECREF(obj);
- objmap.erase(it);
-
-#ifdef _DEBUG
-// post("DEL %p\n",obj);
-#endif
- }
-
- // schedule next collect time
- double tm = flext::GetTime();
- if(tm > last+INTV) last = tm,collix = curix;
-}
+/* + +py/pyext - python script object for PD and Max/MSP + +Copyright (c)2002-2005 Thomas Grill (gr@grrrr.org) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#include "pyatom.h" +#include <map> + +#define INTV 0.01 + +typedef std::map<size_t,PyObject *> ObjMap; + +static ObjMap objmap; +static size_t collix = 0,curix = 0; +static double last = 0; + +size_t PyAtom::Register(PyObject *obj) +{ + Collect(); + + Py_INCREF(obj); + objmap[++curix] = obj; + +#ifdef _DEBUG +// post("REG %p (%i)\n",obj,objmap.size()); +#endif + return curix; +} + +PyObject *PyAtom::Retrieve(size_t id) +{ + ObjMap::iterator it = objmap.find(id); + PyObject *ret = it == objmap.end()?NULL:it->second; + Collect(); + return ret; +} + +void PyAtom::Collect() +{ + for(;;) { + ObjMap::iterator it = objmap.begin(); + if(it == objmap.end() || it->first > collix) break; + + PyObject *obj = it->second; + Py_DECREF(obj); + objmap.erase(it); + +#ifdef _DEBUG +// post("DEL %p\n",obj); +#endif + } + + // schedule next collect time + double tm = flext::GetTime(); + if(tm > last+INTV) last = tm,collix = curix; +} |