r/learnpython • u/BluishMontoya • 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
View all comments
Show parent comment
1
u/BluishMontoya Sep 13 '26 edited Sep 13 '26
This becomes far more complicated if you try to use perturbation theory or the mariani-silver algorithm. Perturbation theory is basically necessary to zoom past 1 trillion times magnification, and the mariani-silver alg offers a huge speed boost. The idea is that if you can outline a rectangle, and all the points along the edge are in the mandelbrot set, then you know that everything inside the rectangle is also in the set and you don't have to do the calculations for it.