X Tutup
Skip to content

Improve cython performance#7

Merged
zingale merged 1 commit intosbu-python-class:mainfrom
yut23:mandel-cython-fix
Apr 25, 2024
Merged

Improve cython performance#7
zingale merged 1 commit intosbu-python-class:mainfrom
yut23:mandel-cython-fix

Conversation

@yut23
Copy link
Copy Markdown
Collaborator

@yut23 yut23 commented Apr 25, 2024

np.abs(z[i, j]) calls into Python unnecessarily, and using abs(z[i, j]) instead gives much better results. On my machine with Cython 0.29.37, this runs the test case in 80ms. This is significantly better than numba and f2py, which are tied for second place at ~120ms.

Curiously, I get worse performance (~140ms) with Cython 3.0.5.

I used cythonize -a mandel.pyx to find the slowdown. Before:
mandel-cython-before
and after:
mandel-cython-after

On my machine, with Cython 0.29.37, this runs the test case in 80ms,
significantly better than numba and f2py at ~120ms.
@zingale zingale merged commit 79bc5fe into sbu-python-class:main Apr 25, 2024
@yut23 yut23 deleted the mandel-cython-fix branch April 25, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup