Python のmemoryviewはorをサポートdatetime64
timedelta
していません。Ok。しかし、またはmemoryview
を含む構造化配列のを作成しようとすると、うまくいくように見えます...変数に割り当てない限り!datetime64
timedelta
In [19]: memoryview(zeros(10, dtype=[("A", "m8[s]")]))
Out[19]: <memory at 0x7f1d455d6048>
In [20]: x = memoryview(zeros(10, dtype=[("A", "m8[s]")]))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
ValueError: cannot include dtype 'm' in a buffer
In [21]: x = _19
In [22]: x
Out[22]: <memory at 0x7f1d455d6048>
これは、Python が基本的に機能する方法についての私の理解に深刻な問題をもたらします。(1) とにかく IPythons REPL が出力を割り当て、(2) 関数/クラスには、呼び出し元がその出力で何をしようとしているのかを知る方法がないことを考えるf()
と、どのように異なるのでしょうか?x = f()
_19
memoryview
Python 3.4.1、numpy 1.10.0.dev+fbcc24f、Linux 2.6.32-431.23.3.el6.x86_64、Scientific Linux リリース 6.6 でコードを実行しています。
編集
Python 3.5、numpy 1.10.4 では、次のようになります。
In [50]: memoryview(numpy.zeros(10, dtype=[("A", "m8[s]")]))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
ValueError: cannot include dtype 'm' in a buffer
During handling of the above exception, another exception occurred:
SystemError Traceback (most recent call last)
<ipython-input-50-5d5ac6c085fa> in <module>()
----> 1 memoryview(numpy.zeros(10, dtype=[("A", "m8[s]")]))
SystemError: <class 'memoryview'> returned a result with an error set
問題がどこにあるかはよくわかりませんが、numpy でバグを報告しました。