Page MenuHome

Python API: implement `PoseBone.children` via `Bone.children`.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Oct 1 2021, 3:01 PM.

Details

Summary

Currently PoseBone.children is implemented by a linear scan of
the list of armature bones. This is doubly inefficient, since
not only is it scanning all bones, the obj.data.bones list
is actually synthetic and must be produced by a recursive scan.

Instead, use the Bone.children native RNA property. Also, it
isn't clear why the code was returning a tuple instead of list.

Diff Detail

Repository
rB Blender

Event Timeline

Alexander Gavrilov (angavrilov) requested review of this revision.Oct 1 2021, 3:01 PM
Alexander Gavrilov (angavrilov) created this revision.
Campbell Barton (campbellbarton) requested changes to this revision.EditedOct 4 2021, 11:50 AM

Good catch that the bone children are directly accessible.

I'd prefer to keep the return value a tuple though, as it can be confusing to new developers when they attempt things like:

bone.children.append(other)
bone.children.clear()
bone.children[0] = other

Which will succeed but not do what the developer expects.

This revision now requires changes to proceed.Oct 4 2021, 11:50 AM
Campbell Barton (campbellbarton) added inline comments.
release/scripts/modules/bpy_types.py
382–383

End sentences with full stops.

This revision is now accepted and ready to land.Oct 11 2021, 4:51 AM