From 9b8357c5ecbc9b3e7bb1360d4cd0973ae1da60f9 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 13 Jun 2025 17:03:50 +0500 Subject: [PATCH] entity_instance.__hash__ - reuse id() value for optimization --- src/ifcopenshell-python/ifcopenshell/entity_instance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 60fb9a58e1..da31b702cf 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -536,8 +536,8 @@ class entity_instance: # Proper entity instances have a stable identity by means of the numeric # step id. Selected type instances (such as IfcPropertySingleValue.NominalValue # always have id=0, so we hash - if self.id(): - return hash((self.id(), self.wrapped_data.file_pointer())) + if id_ := self.id(): + return hash((id_, self.wrapped_data.file_pointer())) else: return hash((self.is_a(), self[0], self.wrapped_data.file_pointer()))