NotesOnCython icon indicating copy to clipboard operation
NotesOnCython copied to clipboard

Some notes on using Cython to increase the performance of Python code.

Results 7 NotesOnCython issues
Sort by recently updated
recently updated
newest added

typed cpdef has same speed as cdef function NOTE: time in table is completely random number

def fib_cached(n, cache={}): if n < 2: return n try: val = cache[n] except KeyError: val = fib(n-2) + fib(n-1) cache[n] = val return val Maybe there is a typo...

There are lots of ways to write Cython. I normally suggest writing the optimised function with a pure C interface, declared "nogil". The nogil declaration tells the Cython compiler there...

This PR updates the notes to include benchmarks for using a typed cpdef function for the Fibonacci function (recursive algorithm). in more details: - All typed functions now return `long`...