From 3499c50d7d24da7c2e173b28321922be39d500b0 Mon Sep 17 00:00:00 2001 From: Andrej Date: Wed, 11 Jun 2025 12:49:47 +0500 Subject: [PATCH] entity_instance.__getattr__ - small optimization for inverse attrs Stop iterating early and don't build a list to make it a bit more optimized. Though I'm unsure if anyone is really using `unpack_non_aggregate_inverses` --- src/ifcopenshell-python/ifcopenshell/entity_instance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 476ed11784..2d9d3d3989 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -206,7 +206,7 @@ class entity_instance: schema_name = self.wrapped_data.is_a(True).split(".")[0] ent: ifcopenshell_wrapper.entity ent = ifcopenshell_wrapper.schema_by_name(schema_name).declaration_by_name(self.is_a()) - inv = [i for i in ent.all_inverse_attributes() if i.name() == name][0] + inv = next(i for i in ent.all_inverse_attributes() if i.name() == name) if (inv.bound1(), inv.bound2()) == (-1, -1): if vs: vs = vs[0]