From 1996efe7aa2e0edc9887ad34bc59e2ab911e2d02 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 1 Oct 2021 15:30:12 +0300 Subject: Python API: implement `PoseBone.children` via `Bone.children`. 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 generated from Bone children lists. Instead, use the `Bone.children` native RNA property. Differential Revision: https://developer.blender.org/D12727 --- release/scripts/modules/bpy_types.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'release/scripts/modules/bpy_types.py') diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 8a1615ad99f..26efb6e3307 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -378,10 +378,9 @@ class PoseBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup): def children(self): obj = self.id_data pbones = obj.pose.bones - self_bone = self.bone - return tuple(pbones[bone.name] for bone in obj.data.bones - if bone.parent == self_bone) + # Use Bone.children, which is a native RNA property. + return tuple(pbones[bone.name] for bone in self.bone.children) class Bone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup): -- cgit v1.2.3