Open jakirkham opened 5 years ago
FWIW this can happen without cybuffer
.
In [1]: import numpy as np
In [2]: a = np.datetime64('2015-07-04 12:59:59.50', 'ns')[None]
In [3]: memoryview(a)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-dd900d27ccee> in <module>
----> 1 memoryview(a)
ValueError: cannot include dtype 'M' in a buffer
Looking a bit more closely, it appears this is actually coming from NumPy. We could certainly circumvent this by checking for a NumPy array and casting it if needed. Though it's unclear whether doing this implicitly is better than just having users do this explicitly.
Description
Currently
datetime
andtimedelta
objects are not supported. This is essentially a consequence of the fact thatmemoryview
s themselves lack support for these types. That said, a reasonable fix for this kind of problem involves casting the data to another type first (e.g.int64
) and then building amemoryview
using that casting.What I Did