From 24dc0482acfcbde8af305fee85085357e8047bf9 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Sat, 3 May 2025 08:41:01 +1000 Subject: [PATCH] PyAPI: minor optimization using iterators for contains checks Avoid building a list to perform a __contains__ check. Ref !138346 --- scripts/modules/bpy_types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/modules/bpy_types.py b/scripts/modules/bpy_types.py index ed4cc07ef3b..a3aabb8f6b2 100644 --- a/scripts/modules/bpy_types.py +++ b/scripts/modules/bpy_types.py @@ -142,9 +142,9 @@ class Texture(_types.ID): """Materials that use this texture""" import bpy return tuple(mat for mat in bpy.data.materials - if self in [slot.texture + if self in (slot.texture for slot in mat.texture_slots - if slot] + if slot) ) @property @@ -153,10 +153,10 @@ class Texture(_types.ID): import bpy return tuple( obj for obj in bpy.data.objects if - self in [ + self in ( mod.texture for mod in obj.modifiers - if mod.type == 'DISPLACE'] + if mod.type == 'DISPLACE') )