Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # lst = range(500)
- # 22 us
- def lstcomp_test(lst):
- return [x for x in lst]
- # 65 us
- def for_test(lst):
- out = []
- for x in lst:
- out.append(x)
- return out
- # 77 us
- def for_enum(lst):
- out = []
- for i,x in enumerate(lst):
- out.append(x)
- return out
- # 87 us
- def for_enum_lookup(lst):
- out = []
- for i,x in enumerate(lst):
- out.append(lst[i])
- return out
- # 90 us
- def for_ugly(lst):
- out = []
- for i in range(len(lst)):
- out.append(lst[i])
- return out
- # 170 us
- def while_test(lst):
- out = []
- i = 0
- while i < len(lst):
- out.append(lst[i])
- i+=1
- return out
- # 740 us
- def for_test_copy(lst):
- out = []
- for x in lst:
- out = out + [x]
- return out
- # 810 us
- def for_ugly_copy(lst):
- out = []
- for i in range(len(lst)):
- out = out + [lst[i]]
- return out
Add Comment
Please, Sign In to add comment