Skip to content

Instantly share code, notes, and snippets.

@biancarosa
Created July 23, 2020 16:00
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 biancarosa/ace9ee9232792495ee86a82259ba8a55 to your computer and use it in GitHub Desktop.
Save biancarosa/ace9ee9232792495ee86a82259ba8a55 to your computer and use it in GitHub Desktop.
import cProfile
import timeit
import ctypes
N = 100000
start = timeit.default_timer()
array = (N * ctypes.c_int)()
stop = timeit.default_timer()
print('Time: ', stop - start)
start = timeit.default_timer()
array = (N * ctypes.c_int64)()
stop = timeit.default_timer()
print('Time: ', stop - start)
start = timeit.default_timer()
array = (N * ctypes.py_object)()
stop = timeit.default_timer()
print('Time: ', stop - start)
@biancarosa
Copy link
Author

Time: 0.0003639560000010533
Time: 0.0007921180003904738
Time: 0.0008451479998257128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment