slowness python

Hi all.

I’ve just written an script that create an armature for every object in the scene. the armature has only one main bone.

In my scene there are 5300 objects.

I have some slowness problems. For every object in the scene, i use bpy.ops.object.add(…) to create the armature, and that action is 0,5s long. The creation and positioning of the main bone is about 0,1s.

This times wihout skinning the objects.

i tested to run the script in background mode, but unfortunately the times are very similar. is there any tip to make this type of loops more efficiently??

Thanks!! (1.09 KB)

5300 !!! What kind of things are you making ?
Have you tried to create the armature just once and then use the object_utils.object_data_add(context, data, operator) (after having imported object_utils from bpy_extras)? I didn’t test it, but it would avoid to create the armature each time. And i tried with just two, and you can pose each aramtures independantly even if they are the same data (I was surprised by that).

it’s a matter of the internals inherit with listing items through iterators and likewise yielding to input, thereby the solution is to get to know the rna python implementation of sliced lists, ie: list[0:100] instead of for anItem in list.
fyi this is not implemented.
Oh and also check this out i can iterate ten fold times faster with a simple map call like:
mapPoints = list(map(lambda x,y: [([0]+y,[1],[2]) for n in range(len(y))] , range(0,250,2)))

i don’t know. i have tried both ways. thanks for the advices.

Jackes, i didn’t know about that function, but i’ve got the same problems. i have tested with 2300 objects. at start, the performance is good, but the time for each iteration is growing continuously

Brockyl, i’ve already readen about map function. But i could not making work fine with Blender operators, or general blender api functions.

i hope Bart write the performance tips wiki of blender python api, hehe.

thank you very much

another thing here deselect record history
that should improve it !

happy 2.6