Elliott Sales de Andrade
bc041de0db
Fix buffer protocol implementation ( #5407 )
...
* Fix buffer protocol implementation
According to the buffer protocol, `ndim` is a _required_ field [1], and
should always be set correctly. Additionally, `shape` should be set if
flags includes `PyBUF_ND` or higher [2]. The current implementation only
set those fields if flags was `PyBUF_STRIDES`.
[1] https://docs.python.org/3/c-api/buffer.html#request-independent-fields
[2] https://docs.python.org/3/c-api/buffer.html#shape-strides-suboffsets
* Apply suggestions from review
* Obey contiguity requests for buffer protocol
If a contiguous buffer is requested, and the underlying buffer isn't,
then that should raise. This matches NumPy behaviour if you do something
like:
```
struct.unpack_from('5d', np.arange(20.0)[::4]) # Raises for contiguity
```
Also, if a buffer is contiguous, then it can masquerade as a
less-complex buffer, either by dropping strides, or even pretending to
be 1D. This matches NumPy behaviour if you do something like:
```
a = np.full((3, 5), 30.0)
struct.unpack_from('15d', a) # --> Produces 1D tuple from 2D buffer.
```
* Handle review comments
* Test buffer protocol against NumPy
* Also check PyBUF_FORMAT results
2024-11-05 10:14:24 -08:00
..
2024-09-13 00:18:29 -04:00
2024-06-22 00:55:00 -04:00
2024-10-07 14:12:04 -07:00
2024-10-07 14:12:04 -07:00
2024-09-13 00:18:29 -04:00
2024-10-07 14:12:04 -07:00
2024-07-29 11:10:03 -07:00
2024-06-18 13:54:38 -07:00
2024-06-18 13:54:38 -07:00
2024-09-17 09:47:20 -07:00
2024-06-18 13:54:38 -07:00
2024-10-07 14:12:04 -07:00
2024-09-13 00:18:29 -04:00
2024-09-13 00:18:29 -04:00
2024-09-13 00:18:29 -04:00
2024-08-22 00:27:50 -04:00
2022-02-10 12:17:07 -08:00
2024-06-18 13:54:38 -07:00
2024-06-18 13:54:38 -07:00
2024-06-24 08:59:55 -07:00
2024-08-14 18:21:04 -04:00
2024-05-24 12:26:40 -04:00
2024-10-07 14:12:04 -07:00
2022-02-10 12:17:07 -08:00
2024-09-03 10:51:21 -04:00
2024-11-05 10:14:24 -08:00
2024-11-05 10:14:24 -08:00
2024-04-02 11:14:08 -04:00
2024-07-30 09:18:35 -07:00
2024-10-07 14:12:04 -07:00
2024-10-25 08:28:15 -07:00
2024-10-07 14:12:04 -07:00
2024-10-07 14:12:04 -07:00
2022-02-10 12:17:07 -08:00
2024-06-22 00:55:00 -04:00
2024-10-12 11:19:50 -07:00
2024-10-25 08:28:15 -07:00
2022-02-14 11:36:22 -08:00
2024-06-22 00:55:00 -04:00
2024-03-26 13:57:05 -04:00
2024-06-22 00:55:00 -04:00
2024-06-24 08:59:55 -07:00
2024-10-25 08:28:15 -07:00
2024-09-13 00:18:29 -04:00
2024-09-13 00:18:29 -04:00
2024-09-13 00:18:29 -04:00
2024-10-07 14:12:04 -07:00
2024-04-02 11:14:08 -04:00
2024-10-25 08:28:15 -07:00
2021-09-24 12:08:22 -07:00
2024-10-07 14:12:04 -07:00
2024-04-02 11:14:08 -04:00
2024-06-22 00:55:00 -04:00
2024-08-22 00:27:50 -04:00
2024-10-25 08:28:15 -07:00
2022-12-20 05:34:00 -08:00
2024-07-29 11:10:03 -07:00
2024-10-07 14:12:04 -07:00
2022-02-10 12:17:07 -08:00
2024-10-07 14:12:04 -07:00
2024-06-22 00:55:00 -04:00
2022-02-10 12:17:07 -08:00
2024-10-07 14:12:04 -07:00
2024-09-17 09:47:20 -07:00
2023-08-07 20:48:20 -07:00
2024-10-11 20:36:41 -07:00
2022-02-14 11:36:22 -08:00
2024-10-07 14:12:04 -07:00
2022-10-30 08:57:23 -07:00
2024-10-07 14:12:04 -07:00
2022-02-14 11:36:22 -08:00
2024-10-07 14:12:04 -07:00
2024-09-24 10:28:22 -07:00
2024-10-07 14:12:04 -07:00
2022-02-10 12:17:07 -08:00
2024-06-22 00:55:00 -04:00
2024-04-02 11:14:08 -04:00
2024-10-07 14:12:04 -07:00
2024-07-29 11:10:03 -07:00
2024-10-07 14:12:04 -07:00
2022-02-10 12:17:07 -08:00
2024-10-07 14:12:04 -07:00
2024-04-02 11:14:08 -04:00
2024-10-07 14:12:04 -07:00
2024-07-29 11:10:03 -07:00
2024-06-22 00:55:00 -04:00
2022-05-26 11:07:40 -04:00
2024-06-22 00:55:00 -04:00
2024-08-22 00:27:50 -04:00
2024-10-25 08:28:15 -07:00
2022-11-28 07:39:38 -08:00
2024-10-25 08:28:15 -07:00
2022-05-02 12:39:36 -07:00
2024-10-07 14:12:04 -07:00
2023-11-08 12:44:04 -08:00
2024-06-22 00:55:00 -04:00
2024-10-11 20:33:13 -07:00
2024-10-11 20:33:13 -07:00
2024-08-22 00:27:50 -04:00
2024-10-07 14:12:04 -07:00
2024-08-22 00:27:50 -04:00
2024-10-07 14:12:04 -07:00
2024-04-02 11:14:08 -04:00
2024-10-08 10:49:35 -07:00
2024-08-22 00:27:50 -04:00
2024-10-07 14:12:04 -07:00
2024-08-22 00:27:50 -04:00
2024-06-22 00:55:00 -04:00
2024-05-10 17:03:51 -04:00
2024-07-18 14:50:38 -04:00
2024-10-07 14:12:04 -07:00
2024-06-22 00:55:00 -04:00
2024-08-09 13:28:12 -07:00
2024-08-09 13:28:12 -07:00
2019-06-11 23:28:58 +02:00
2024-06-22 00:55:00 -04:00
2023-04-25 14:03:24 -07:00
2024-06-22 00:55:00 -04:00
2023-04-25 14:03:24 -07:00
2024-06-22 00:55:00 -04:00
2023-04-27 07:24:48 -07:00
2024-06-22 00:55:00 -04:00
2024-08-22 00:27:50 -04:00
2024-10-07 14:12:04 -07:00
2024-08-28 20:55:50 -07:00
2024-08-28 20:55:50 -07:00
2021-07-04 19:58:35 -04:00
2021-01-31 17:29:09 -05:00