Skip to content

Conversation

@ashwinvis
Copy link
Contributor

@ashwinvis ashwinvis commented Nov 11, 2025

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?

@ashwinvis ashwinvis force-pushed the ashwin-cython-episode branch from 5001717 to fcaebd3 Compare November 21, 2025 08:49
- :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.

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

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.

HPC: Update to Cython 3.0 syntax with support for type-hints

3 participants