Last active
September 13, 2018 14:06
-
-
Save srusskih/77037c6b6fd8cd9cf55ce52c19f8ae76 to your computer and use it in GitHub Desktop.
Revisions
-
srusskih revised this gist
Sep 13, 2018 . 1 changed file with 2 additions and 2 deletions.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 @@ -11,7 +11,7 @@ def t1(): for i in a: d[i[0]](i) t1()''', number=1000) timeit.timeit(''' @@ -25,4 +25,4 @@ def t2(): for i in a: d[i[0]].append(i) t2()''', number=1000) -
srusskih renamed this gist
Sep 13, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
srusskih revised this gist
Sep 13, 2018 . 1 changed file with 28 additions and 0 deletions.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,28 @@ import timeit timeit.timeit(''' import collections a = [(i, i - 1) for i in range(10000)] def t1(): d = collections.defaultdict(lambda: [].append) for i in a: d[i[0]](i) t1()''') timeit.timeit(''' import collections a = [(i, i - 1) for i in range(10000)] def t2(): d = collections.defaultdict(list) for i in a: d[i[0]].append(i) t2()''') -
srusskih created this gist
Sep 13, 2018 .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,15 @@ import collections a = [(i, i - 1) for i in range(10000)] def t1(): d = collections.defaultdict(lambda: [].append) for i in a: d[i[0]](i) def t2(): d = collections.defaultdict(list) for i in a: d[i[0]].append(i)