[ENH] Support F-contiguous `memoryview`s in `cast`
オープン
@jamie2779 がすでに取り組んでいます。
2025年8月15日 から。
interpreter-core
type-feature
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。