Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # globals_timed.py ??? dang!
- from ctypes import *
- import timeit
- def f1():
- global t
- t += 1
- def f2():
- cv.t += 1
- def f3():
- p[0] += 1
- class Cv(): 0
- cv = Cv()
- cv.t = 0
- t = 0
- n = c_int(0)
- p = pointer(n)
- for i in '.'*10:
- print(timeit.timeit("f1()", setup="from __main__ import f1"))
- print(timeit.timeit("f2()", setup="from __main__ import f2"))
- print(timeit.timeit("f3()", setup="from __main__ import f3"))
- print
- print(t)
- print(cv.t)
- print(n.value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement