question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implementing `__bytes__` on `ndarray`s

See original GitHub issue

It would be useful to have an implementation of __bytes__ for ndarray analogous to NumPy’s. Ideally this would avoid an intermediate copy to a NumPy array (by using things like cuMemcpyDtoH).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
jakirkhamcommented, Mar 4, 2020

Maybe bytes(self.get()) (where self is the ndarray)? This aligns most closely to what NumPy is doing as it uses NumPy’s behavior exactly.

1reaction
jakirkhamcommented, Mar 4, 2020

Thanks for collecting and sharing all of those details with them, Harshan. 😄 Let’s see what they say 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I make a numpy ndarray from bytes? - Stack Overflow
To deserialize the bytes you need np.frombuffer() . tobytes() serializes the array into bytes and the np.frombuffer() deserializes them.
Read more >
numpy.ndarray.tobytes — NumPy v1.24 Manual
Constructs Python bytes showing a copy of the raw contents of data memory. The bytes object is produced in C-order by default.
Read more >
Byte Swapping in NumPy - Scaler Topics
Change the underlying data's byte order while leaving the dtype interpretation alone. This is the function arr.byteswap(). ndarray.byteswap().
Read more >
Numpy ndarray.tobytes() function | Python - GeeksforGeeks
numpy.ndarray.tobytes() function construct Python bytes containing the raw data bytes in the array. Syntax : numpy.ndarray.tobytes(order='C').
Read more >
ndarray, the base class — The ulab book 5.1.0 documentation
The method takes a single keyword argument, inplace , with values True or False , and swaps the bytes in the array.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found