enumerate() is known to be a little slower, but here, you access at least twice to `keys[k]`. What about doing the loop on the keys itself, and increment manually `k`? No lookup in the keys[].