Created
August 8, 2013 10:43
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ In [1]: a = '12345678' In [2]: %timeit [a[max(i-3,0):i] for i in range(len(a), 0, -3)][::-1] 100000 loops, best of 3: 2.19 us per loop In [3]: %timeit format(int(a), ',').split(',') 100000 loops, best of 3: 2.04 us per loop In [4]: %timeit [a[max(0,i-2+(len(a)-1)%3):i+1+(len(a)-1)%3] for i in range(0, len(a), 3)] 100000 loops, best of 3: 2.91 us per loop