This is an automated email from the ASF dual-hosted git repository.

apitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 1ffed20f40 GH-40153: [Python] Update size assumptions for 32-bit 
platforms (#40165)
1ffed20f40 is described below

commit 1ffed20f4008a1b3bd06deb904d94ff668cde42a
Author: Michał Górny <[email protected]>
AuthorDate: Wed Feb 21 09:58:42 2024 +0100

    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 <[email protected]>
    Signed-off-by: Antoine Pitrou <[email protected]>
---
 python/pyarrow/tests/test_pandas.py | 5 +++--
 python/pyarrow/tests/test_schema.py | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/python/pyarrow/tests/test_pandas.py 
b/python/pyarrow/tests/test_pandas.py
index 676cc96151..89a241a27e 100644
--- a/python/pyarrow/tests/test_pandas.py
+++ b/python/pyarrow/tests/test_pandas.py
@@ -2608,8 +2608,9 @@ class TestConvertStructTypes:
                                        ('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()),
diff --git a/python/pyarrow/tests/test_schema.py 
b/python/pyarrow/tests/test_schema.py
index fa75fcea30..8793c9e773 100644
--- a/python/pyarrow/tests/test_schema.py
+++ b/python/pyarrow/tests/test_schema.py
@@ -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)

Reply via email to