r/learnpython • • Sep 13 '26

Cython memoryviews?

I'm using a function I've compiled with cython, and I have to pass it a few very long lists. I'm pretty sure I should be using memoryviews, but do I convert the lists to memoryviews in the python part of my program or the cython part? It would be way better if I could do it in the python part because I'm passing the same lists to the function a few million times.

4 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/appu-195 Sep 20 '26

if it's about python because of Pillow I have complete replacement built in rust

you can try pillow-rs no dependency image processing using rust complete replacement for PIL -> https://github.com/appunni-m/pillow-rs

You can build your vectors directly in rust no need of conversion or numpy etc