How to apply decorators to Cython cpdef functions
问题 I've been playing around with Cython lately and I came across this error when applying a decorator to a Cython function Cdef functions/classes cannot take arbitrary decorators Here is the code I was tinkering with: import functools def memoize(f): computed = {} @functools.wraps(f) def memoized_f(main_arg, *args, **kwargs): if computed.get(main_arg): return computed[main_arg] computed[main_arg] = f(main_arg, *args, **kwargs) return computed[main_arg] return memoized_f @memoize cpdef int fib