While fun to think about – a nice little brain stretcher – this solution smells of cleverness for cleverness' sake.
Arguing that this is a better solution on the grounds of optimization would be salient if this were a function likely to be called thousands of times on a large data set. I just can't imagine that being the case in this instance.
I subscribe to the idea that when given the choice between 'clever' optimized code, and code which is instantly readable and maintainable, it's best to opt for the latter – unless you're trying to resolve an execution bottleneck.