hcrosse commented on code in PR #4280:
URL: https://github.com/apache/iceberg-python/pull/4280#discussion_r4462673645


##########
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:

Review Comment:
   I changed `Record.__eq__` to compare each position once in a single loop and 
added a test that bounds `Leaf.__eq__` calls for a value nested 20 records 
deep. For unequal records nested 20 deep, `Record.__eq__` calls drop from 
1,048,575 to 20 and the time from 474 ms to 8.6 µs. Equal three-field records 
now cost about 442 ns instead of about 98 ns.



-- 
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