Skip to content

Commit

Permalink
apacheGH-40153: [Python] Update size assumptions for 32-bit platforms (
Browse files Browse the repository at this point in the history
…apache#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: apache#40153

Authored-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
mgorny authored and thisisnic committed Mar 8, 2024
1 parent b52bbb3 commit 3dadd49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions python/pyarrow/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2608,8 +2608,9 @@ def test_from_numpy_nested(self):
('yy', np.bool_)])),
('y', np.int16),
('z', np.object_)])
# Note: itemsize is not a multiple of sizeof(object)
assert dt.itemsize == 12
# Note: itemsize is not necessarily a multiple of sizeof(object)
# object_ is 8 bytes on 64-bit systems, 4 bytes on 32-bit systems
assert dt.itemsize == (12 if sys.maxsize > 2**32 else 8)
ty = pa.struct([pa.field('x', pa.struct([pa.field('xx', pa.int8()),
pa.field('yy', pa.bool_())])),
pa.field('y', pa.int16()),
Expand Down
3 changes: 2 additions & 1 deletion python/pyarrow/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ def test_schema_sizeof():
pa.field('bar', pa.string()),
])

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

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

0 comments on commit 3dadd49

Please sign in to comment.