From fc079f8482a04b3e331fb4252549ce7e5c5a307b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jan 2006 05:38:39 +0000 Subject: [PATCH] made scene.getChildren() a heap faster. 983.3 times faster in my test. getting 7200 objects did take: 1.18 sec, now 0.0012 sec It was doing a full object list lookup for every object in the scenes base using the name to compare. now it just gets the object directly from the base and converts it to a python object, adding it to the list. - Cam --- source/blender/python/api2_2x/Scene.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c index 74510b48dcb..fd3ebd51318 100644 --- a/source/blender/python/api2_2x/Scene.c +++ b/source/blender/python/api2_2x/Scene.c @@ -845,22 +845,16 @@ static PyObject *Scene_getChildren( BPy_Scene * self ) while( base ) { object = base->object; - - name = Py_BuildValue( "(s)", object->id.name + 2 ); - if( !name ) - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "Py_BuildValue() failed" ); - - bpy_obj = M_Object_Get( Py_None, name ); - Py_DECREF ( name ); - + + bpy_obj = Object_CreatePyObject( object ); + if( !bpy_obj ) return EXPP_ReturnPyObjError( PyExc_RuntimeError, "couldn't create new object wrapper" ); PyList_Append( pylist, bpy_obj ); Py_XDECREF( bpy_obj ); /* PyList_Append incref'ed it */ - + base = base->next; }