I assume len is Py_ssize_t for calling into python. Is it guaranteed that the cast to int can't go wrong?