rust-python-example icon indicating copy to clipboard operation
rust-python-example copied to clipboard

faster cython version for bytes

Open zed opened this issue 7 years ago • 0 comments

def count_doubles(bytes data):
    cdef Py_ssize_t count = 0, i
    cdef char *s = data  # no copy
    for i in range(len(data) - 1):
        count += (s[i] == s[i + 1])
    return count

zed avatar Nov 23 '17 13:11 zed