MCPcopy Create free account
hub / github.com/apache/arrow / test_array_uses_memory_pool

Function test_array_uses_memory_pool

python/pyarrow/tests/test_pandas.py:3864–3887  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3862# to_pandas uses MemoryPool
3863
3864def test_array_uses_memory_pool():
3865 # ARROW-6570
3866 N = 10000
3867 arr = pa.array(np.arange(N, dtype=np.int64),
3868 mask=np.random.randint(0, 2, size=N).astype(np.bool))
3869
3870 # In the case the gc is caught loading
3871 gc.collect()
3872
3873 prior_allocation = pa.total_allocated_bytes()
3874
3875 x = arr.to_pandas()
3876 assert pa.total_allocated_bytes() == (prior_allocation + N * 8)
3877 x = None # noqa
3878 gc.collect()
3879
3880 assert pa.total_allocated_bytes() == prior_allocation
3881
3882 # zero copy does not allocate memory
3883 arr = pa.array(np.arange(N, dtype=np.int64))
3884
3885 prior_allocation = pa.total_allocated_bytes()
3886 x = arr.to_pandas() # noqa
3887 assert pa.total_allocated_bytes() == prior_allocation
3888
3889
3890def test_singleton_blocks_zero_copy():

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.45

Tested by

no test coverage detected