%load_ext cythonmagic %%cython --annotate from libc.stdlib cimport strtol as _strtol def strtol(bytes n, int base=10): cdef int ret cdef char *nptr = n cdef char *endptr ret = _strtol(nptr, &endptr, base) if endptr == nptr or endptr[0] != 0: raise ValueError("Invalid string %r at at character %d" % (n, endptr-nptr+1)) return ret strtol('hello', base=36) %timeit strtol('hello', base=36)