()
| 468 | @requires_numpy_version("2.1.0") |
| 469 | @check_bytes_allocated |
| 470 | def test_from_dlpack_zero_copy(): |
| 471 | expected = np.array([1, 2, 3], dtype=np.int64) |
| 472 | tensor = pa.Tensor.from_dlpack(expected) |
| 473 | result = tensor.to_numpy() |
| 474 | # Zero-copy import: mutating the source is visible through the tensor. |
| 475 | expected[0] = 100 |
| 476 | assert result[0] == 100 |
| 477 | # Same for mutating the result |
| 478 | result[1] = 42 |
| 479 | assert expected[1] == 42 |
| 480 | |
| 481 | |
| 482 | @requires_numpy_version("2.1.0") |