Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # module_timeit_on_list_count_vs_dict.py
- import timeit
- print timeit.timeit('len(set(s))<=1', 's=[1]*5000', number=10000)
- print timeit.timeit('len(set(s))<=1', 's=[1]*4999+[2]', number=10000)
- print timeit.timeit('s.count(s[0])==len(s)', 's=[1]*5000', number=10000)
- print timeit.timeit('s.count(s[0])==len(s)', 's=[1]*4999+[2]', number=10000)
- s=[1]*5
- print s, s.count(s[0])==len(s)
- s=[1]*4+[2]
- print s, s.count(s[0])==len(s)
- s=[1]*5
- print s, len(set(s))<=1
- s=[1]*4+[2]
- print s, len(set(s))<=1
- s=[(1,0)]*5
- print s, len(set(s))<=1
- s=[(1,0)]*4+[(1,2)]
- print s, len(set(s))<=1
- s=[[1,0]]*5
- print s, len(set(map(str,s)))<=1
- s=[[1,0]]*4+[[1,2]]
- print s, len(set(map(str,s)))<=1
- # !!! Needs to be a immutable unlike the count method
- s=[[1,0]]*5
- print s, len(set(s))<=1
- s=[[1,0]]*4+[[1,2]]
- print s, len(set(s))<=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement