Using try-except here might be a bit faster in cases with more than a few repeats.  I get only modest improvements on my tiny benchmark though.