Skip to content

typed arrays to numpy #104

@crackwitz

Description

@crackwitz

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions