You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was just trying to generate some numbers, stick them into a new Float64Array(N), and return them to Python.
To my surprise, the returned object wasn't even a list. I can't index into it, result[0] just fails:
ArgumentError: Python argument types in
JSObject.__getitem__(JSObject, int)
did not match C++ signature:
__getitem__(class CJavascriptObject {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)
But result["0"] does work... That expression on a normal javascript list fails, rightfully, with TypeError: list indices must be integers.
dir(result) showed me [0, 1, 2, ..., N-1], i.e. the dir() returned a list of numbers, which is extremely odd because dir() on any other python object always returns a bunch of strings, which represent the methods of that object.
Calling np.asarray() on a regular (javascript) list object actually gives me something sensible, but calling it on this object just results in a numpy array of dtype=object, which is not useful. It does not appear to support iter() and next(). The regular javascript list does support those.
I think it'd be great to be able to use typed arrays.
If complete numpy adaptation is too complicated, I'd be happy to get something that presents buffer access at least. The less data to copy, the better.
The text was updated successfully, but these errors were encountered:
When I started porting PyV8, it did not use to provide support for TypedArrays. And that is reasonably the reason behind this misbehaving. The wrapper is not aware of the existence of such data type(s) and wraps to a generic object. Which is what you are seeing in your tests. Adding this support has always been in my TODO list but never did that for lack of time. I'll try to spend some cycles on that as soon as possible. Thanks for your patience.
Oh don't worry. I just thought to mention this. It's a very useful project and served me well already. I did eventually fill a regular list... or several. I had to do my calculations in chunks because too big a list will just crash the Jupyter kernel (no python-level exceptions).
I was just trying to generate some numbers, stick them into a
new Float64Array(N)
, and return them to Python.To my surprise, the returned object wasn't even a list. I can't index into it,
result[0]
just fails:But
result["0"]
does work... That expression on a normal javascript list fails, rightfully, withTypeError: list indices must be integers
.dir(result)
showed me[0, 1, 2, ..., N-1]
, i.e. the dir() returned a list of numbers, which is extremely odd because dir() on any other python object always returns a bunch of strings, which represent the methods of that object.Calling
np.asarray()
on a regular (javascript) list object actually gives me something sensible, but calling it on this object just results in a numpy array ofdtype=object
, which is not useful. It does not appear to supportiter()
andnext()
. The regular javascript list does support those.I think it'd be great to be able to use typed arrays.
If complete numpy adaptation is too complicated, I'd be happy to get something that presents buffer access at least. The less data to copy, the better.
The text was updated successfully, but these errors were encountered: