Copilot commented on code in PR #4281:
URL: https://github.com/apache/iceberg-python/pull/4281#discussion_r4462360283


##########
pyiceberg/typedef.py:
##########
@@ -196,8 +201,19 @@ def __getitem__(self, pos: int) -> Any:
         return self._data[pos]
 
     def __eq__(self, other: Any) -> bool:
-        """Return the equality of two instances of the Record class."""
-        return self._data == other._data if isinstance(other, Record) else 
False
+        """Compare records, treating NaN floats at the same position as 
equal."""
+        if not isinstance(other, Record):
+            return False
+        if self._data == other._data:
+            return True
+        if len(self._data) != len(other._data):
+            return False
+        for a, b in zip(self._data, other._data, strict=True):

Review Comment:
   The list fast path recursively compares nested Records, then the fallback 
repeats that comparison at line 212 when they differ. This doubles the work at 
each nesting level, even without NaNs: two 16-level nested Records ending in 
`0.0` versus `1.0` now require 131,071 equality calls instead of 17. Please use 
a single-pass comparison, or otherwise avoid comparing each unequal nested 
Record twice, so equality remains linear in nesting depth.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to