```cython 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 ```