Skip to content

Instantly share code, notes, and snippets.

Created June 13, 2014 19:39
Show Gist options
  • Save anonymous/b45e051131cbf6485649 to your computer and use it in GitHub Desktop.
Save anonymous/b45e051131cbf6485649 to your computer and use it in GitHub Desktop.
test
from timeit import Timer
setup_common = """\
from mathutils import Vector
from random import random
num_rands = 10000
a_ran = (random() for i in range(num_rands))
b_ran = (random() for i in range(num_rands))
c_ran = (random() for i in range(num_rands))
vector_list = [Vector((a,b,c)) for a,b,c in zip(a_ran, b_ran, c_ran)]
def do_slices():
tuple_list = [v[:] for v in vector_list]
def do_literals():
tuple_list = [v.to_tuple() for v in vector_list]
"""
def test():
t1 = Timer("do_slices()", setup=setup_common)
print("slices: ", min(t1.repeat(3,1000)))
t2 = Timer("do_literals()", setup=setup_common)
print("literals: ", min(t2.repeat(3,1000)))
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment