Docker-compose no longer building image (AttributeError: cython_sources)

Important security disclaimer: I would strongly discourage anyone downgrading PyYAML to 5.3.1, as versions before 5.4 all have a known CVE — CVE-2020-14343. This issue was caused by an incompatibility of PyYAML<6.0.1 compiled under the version of Cython>=3.0, released on July 17, 2023. This has now been fixed by a new release of PyYAML, tagged …

Read more

Idiomatic way to do list/dict in Cython?

Cython now has template support, and comes with declarations for some of the STL containers. See http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html#standard-library Here’s the example they give: from libcpp.vector cimport vector cdef vector[int] vect cdef int i for i in range(10): vect.push_back(i) for i in range(10): print vect[i]

Numpy vs Cython speed

With slight modification, version 3 becomes twice as fast: @cython.boundscheck(False) @cython.wraparound(False) @cython.nonecheck(False) def process2(np.ndarray[DTYPE_t, ndim=2] array): cdef unsigned int rows = array.shape[0] cdef unsigned int cols = array.shape[1] cdef unsigned int row, col, row2 cdef np.ndarray[DTYPE_t, ndim=2] out = np.empty((rows, cols)) for row in range(rows): for row2 in range(rows): for col in range(cols): out[row, col] …

Read more