ModularM
Modular3y ago
1 reply
Sam Nardoni

Mojo Pointer to Python bytes?

Hello,

Is there a way to create a Python bytes object from a Mojo Pointer?

Context: I have image/pixel data stored in contiguous memory in Mojo-land. I want to load this into Python-land using pillow. Pillow offers a Image.frombytes function, which seems like it may do the job. But I need to provide it a Python bytes. I don't mind if the data is copied.

I've tried setting the data pixel-by-pixel, but it is sssllloooowwwww.
Was this page helpful?