Skip to content

Instantly share code, notes, and snippets.

@cscorley
Created September 8, 2013 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cscorley/6488362 to your computer and use it in GitHub Desktop.
Save cscorley/6488362 to your computer and use it in GitHub Desktop.
from timeit import timeit
from ctypes import *
size = 10
l = list()
arr = (c_int * size)()
def test(x):
for n in range(x):
l.append(n)
def testarr(x):
for n in range(x):
arr[n] = n
if __name__ == '__main__':
print(timeit("test(size)", setup="from __main__ import test, size"))
print(timeit("testarr(size)", setup="from __main__ import testarr, size"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment