Do I need to handle overflow here like @storchaka pointed out? gh-118184: Support tuples for `find`, `index`, `rfind` & `rindex` by nineteendo · Pull Request #119501 · python/cpython · GitHub
It’s going to make the implementation messy.
#define FIND_CHUNK_SIZE 10000
...
Py_ssize_t len = PyUnicode_GET_LENGTH(str);
ADJUST_INDICES(start, end, len);
// This addition
for (; result == -1 && start <= end; start += FIND_CHUNK_SIZE) {
I can’t even create such a long string:
>>> string = "a" * 9223372036854775807
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
string = "a" * 9223372036854775807
~~~~^~~~~~~~~~~~~~~~~~~~~
MemoryError