Skip to content

Commit 1ffed20

Browse files
authored
GH-40153: [Python] Update size assumptions for 32-bit platforms (#40165)
### Rationale for this change This fixes two tests on 32-bit platforms (tested on x86 specifically). ### What changes are included in this PR? - update the `pd.object_` size assumption to 4 bytes on 32-bit platforms - update the `pa.schema` size assumptions to be twice smaller on 32-bit platforms ### Are these changes tested? The changes fix tests. ### Are there any user-facing changes? Only test fixes. * Closes: #40153 Authored-by: Michał Górny <mgorny@gentoo.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent 29a0581 commit 1ffed20

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

python/pyarrow/tests/test_pandas.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,8 +2608,9 @@ def test_from_numpy_nested(self):
26082608
('yy', np.bool_)])),
26092609
('y', np.int16),
26102610
('z', np.object_)])
2611-
# Note: itemsize is not a multiple of sizeof(object)
2612-
assert dt.itemsize == 12
2611+
# Note: itemsize is not necessarily a multiple of sizeof(object)
2612+
# object_ is 8 bytes on 64-bit systems, 4 bytes on 32-bit systems
2613+
assert dt.itemsize == (12 if sys.maxsize > 2**32 else 8)
26132614
ty = pa.struct([pa.field('x', pa.struct([pa.field('xx', pa.int8()),
26142615
pa.field('yy', pa.bool_())])),
26152616
pa.field('y', pa.int16()),

python/pyarrow/tests/test_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,8 @@ def test_schema_sizeof():
681681
pa.field('bar', pa.string()),
682682
])
683683

684-
assert sys.getsizeof(schema) > 30
684+
# Note: pa.schema is twice as large on 64-bit systems
685+
assert sys.getsizeof(schema) > (30 if sys.maxsize > 2**32 else 15)
685686

686687
schema2 = schema.with_metadata({"key": "some metadata"})
687688
assert sys.getsizeof(schema2) > sys.getsizeof(schema)

0 commit comments

Comments
 (0)