Skip to content

Commit 2858b1e

Browse files
perf: Faster local data comparison using idenitity (#1738)
1 parent 545cdca commit 2858b1e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

bigframes/core/local_data.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def from_arrow(cls, table: pa.Table) -> LocalTableMetadata:
5454

5555
@dataclasses.dataclass(frozen=True)
5656
class ManagedArrowTable:
57-
data: pa.Table = dataclasses.field(hash=False)
58-
schema: schemata.ArraySchema = dataclasses.field(hash=False)
57+
data: pa.Table = dataclasses.field(hash=False, compare=False)
58+
schema: schemata.ArraySchema = dataclasses.field(hash=False, compare=False)
5959
id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
6060

6161
@functools.cached_property

tests/unit/test_local_data.py

+13
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,16 @@ def test_local_data_well_formed_round_trip_sliced():
6464
result.reset_index(drop=True),
6565
check_dtype=False,
6666
)
67+
68+
69+
def test_local_data_equal_self():
70+
local_entry = local_data.ManagedArrowTable.from_pandas(pd_data)
71+
assert local_entry == local_entry
72+
assert hash(local_entry) == hash(local_entry)
73+
74+
75+
def test_local_data_not_equal_other():
76+
local_entry = local_data.ManagedArrowTable.from_pandas(pd_data)
77+
local_entry2 = local_data.ManagedArrowTable.from_pandas(pd_data[::2])
78+
assert local_entry != local_entry2
79+
assert hash(local_entry) != hash(local_entry2)

0 commit comments

Comments
 (0)