[Bf-python] a remark concerning functions returning lists

Jacques Guignot guignot at wanadoo.fr
Wed Jun 18 20:03:19 CEST 2003


I saw that many functions returning a list follow this scheme :

1) Create a list of appropriate size
2) insert items in this list
3) return the list.
Example :

camlist = PyList_New (BLI_countlist (&(G.main->world)));
PyList_SET_ITEM (camlist, index, pystr);
 return camlist;


I think this procedure should be replaced by a simpler one :

1) Create an empty list
2) append the elements
3) return the list

Example :
PyObject *pylist= PyList_New(0);
PyList_Append (pylist, bpy_obj);
return pylist;

What do you think ?








More information about the Bf-python mailing list