IIRC, a slice has a time complexity of O(k) (with k == the number of items). So, going over two halves of the array are roughly equivalent to going over the array once. I imagine there is a bit of overhead for the stepping, but I doubt it's much. I'm really not sure how you'd optimize this code in pure python.

You have a good point there, indeed.

I would measure it against a simple

`if index is even .. else`

loop, but that's probably not any faster. Thanks for the heads up!IIRC, a slice has a time complexity of O(k) (with k == the number of items). So, going over two halves of the array are roughly equivalent to going over the array once. I imagine there is a bit of overhead for the stepping, but I doubt it's much. I'm really not sure how you'd optimize this code in pure python.

Not really best practice, because you traverse the array twice, but at least it's clear :-)

nice one