| 2495 | |
| 2496 | @pickle_test_parametrize |
| 2497 | def test_array_pickle_protocol5(data, typ, pickle_module): |
| 2498 | # Test zero-copy pickling with protocol 5 (PEP 574) |
| 2499 | array = pa.array(data, type=typ) |
| 2500 | addresses = [buf.address if buf is not None else 0 |
| 2501 | for buf in array.buffers()] |
| 2502 | |
| 2503 | for proto in range(5, pickle_module.HIGHEST_PROTOCOL + 1): |
| 2504 | buffers = [] |
| 2505 | pickled = pickle_module.dumps(array, proto, buffer_callback=buffers.append) |
| 2506 | result = pickle_module.loads(pickled, buffers=buffers) |
| 2507 | assert array.equals(result) |
| 2508 | |
| 2509 | result_addresses = [buf.address if buf is not None else 0 |
| 2510 | for buf in result.buffers()] |
| 2511 | assert result_addresses == addresses |
| 2512 | |
| 2513 | |
| 2514 | @pytest.mark.numpy |