BGE Python API
Use 'const char *' rather then the C++ 'STR_String' type for the attribute identifier of python attributes. Each attribute and method access from python was allocating and freeing the string. A simple test with getting an attribute a loop shows this speeds up attribute lookups a bit over 2x.
This commit is contained in:
@@ -76,8 +76,8 @@ class SCA_PythonController : public SCA_IController
|
||||
static const char* sPyAddActiveActuator__doc__;
|
||||
static PyObject* sPyAddActiveActuator(PyObject* self,
|
||||
PyObject* args);
|
||||
virtual PyObject* _getattr(const STR_String& attr);
|
||||
virtual int _setattr(const STR_String& attr, PyObject *value);
|
||||
virtual PyObject* _getattr(const char *attr);
|
||||
virtual int _setattr(const char *attr, PyObject *value);
|
||||
|
||||
KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetSensors);
|
||||
KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetActuators);
|
||||
|
Reference in New Issue
Block a user