[ENH] Support F-contiguous `memoryview`s in `cast`
@jamie2779 đang làm issue này rồi.
Từ ngày 15/8/2025.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Currently memoryview.cast requires C-contiguous data when going from N-D to 1-D. As a result F-contiguous data is not supported. Please see example below:
>>> mv.c_contiguous
False
>>> mv.f_contiguous
True
>>> mv.cast("B")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: memoryview: casts are restricted to C-contiguous views
However as F-contiguous data is still contiguous and can be viewed in 1-D, it seems possible to support this type of data as well. PickleBuffer's raw method does appear to support both C & F contiguous data. Building off the example above:
>>> from pickle import PickleBuffer
>>> pb = PickleBuffer(mv)
>>> pb.raw()
<memory at 0x1105cec70>
This would be useful when interacting with other libraries that work with this kind of data. That said, don't know if there is other context behind the C-contiguous constraint that I may be missing here.
Linked PRs
- gh-137803
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Đánh giá
Issue này chưa được đánh giá.