-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor cython episode #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
%%cython -a magic only works there.
5001717 to
fcaebd3
Compare
This reverts commit 1d9cde6.
| - :cython:ref:`cpdef <cpdef>` function combines both ``cdef`` and ``def``. | ||
| - Cython will generate a ``cdef`` function for C types and a ``def`` function for Python types. | ||
| - In terms of performance, ``cpdef`` functions may be *as fast as* those using ``cdef`` and might be as slow as ``def`` declared functions. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashwinvis since this example, when i switch between "pure python" and "cython", it jumps a little bit which is disturbing
| @cython.wraparound(False) | ||
| def normalize(double[:] x): | ||
| """Normalize a 1D array by dividing all its elements using its root-mean-square (RMS) value.""" | ||
| cdef Py_ssize_t i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashwinvis do you have to mention data type like Py_ssize_t somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will try to use usize or uint and see if works.
Fixes ENCCS/hpda-python#89
Add cython lesson from hpda-python as is
Add Cython code with pure python syntax, with notebook
Fix broken installation due to pip finding python files under content
Add pairwise distance exercise with TODO
Add bubble sort example with numpy maybe?