import time
class DD(object):
def __init__(self):
self.d = {'pos x':22,'pos y':15,'anchor x':1,'anchor y':33}
def doit(self):
x = self.d['pos x']+self.d['anchor x']
y = self.d['pos y']+self.d['anchor y']
class D(object):
def __init__(self):
self.pos = {'x':22,'y':15}
self.anchor = {'x':1,'y':33}
def doit(self):
x = self.pos['x']+self.anchor['x']
y = self.pos['y']+self.anchor['y']
class LL(object):
def __init__(self):
self.l = [22,15,1,33]
def doit(self):
x = self.l[0]+self.l[2]
y = self.l[1]+self.l[3]
class L(object):
def __init__(self):
self.pos = [22,15]
self.anchor = [1,33]
def doit(self):
x = self.pos[0]+self.anchor[0]
y = self.pos[1]+self.anchor[1]
class T(object):
def __init__(self):
self.pos = (22,15)
self.anchor = (1,33)
def doit(self):
x = self.pos[0]+self.anchor[0]
y = self.pos[1]+self.anchor[1]
class V(object):
def __init__(self):
self.pos_x = 22
self.pos_y = 15
self.anchor_x = 1
self.anchor_y = 33
def doit(self):
x = self.pos_x+self.anchor_y
y = self.pos_y+self.anchor_y
n = 200000
a = DD()
t = time.clock()
for i in xrange(n):
a.doit()
print(time.clock()-t)
a = D()
t = time.clock()
for i in xrange(n):
a.doit()
print(time.clock()-t)
a = LL()
t = time.clock()
for i in xrange(n):
a.doit()
print(time.clock()-t)
a = L()
t = time.clock()
for i in xrange(n):
a.doit()
print(time.clock()-t)
a = T()
t = time.clock()
for i in xrange(n):
a.doit()
print(time.clock()-t)
a = V()
t = time.clock()
for i in xrange(n):
a.doit()
print(time.clock()-t)
aW1wb3J0IHRpbWUKCgpjbGFzcyBERChvYmplY3QpOgoKICAgIGRlZiBfX2luaXRfXyhzZWxmKToKCiAgICAgICAgc2VsZi5kID0geydwb3MgeCc6MjIsJ3BvcyB5JzoxNSwnYW5jaG9yIHgnOjEsJ2FuY2hvciB5JzozM30KCiAgICBkZWYgZG9pdChzZWxmKToKCiAgICAgICAgeCA9IHNlbGYuZFsncG9zIHgnXStzZWxmLmRbJ2FuY2hvciB4J10KICAgICAgICB5ID0gc2VsZi5kWydwb3MgeSddK3NlbGYuZFsnYW5jaG9yIHknXQoKCmNsYXNzIEQob2JqZWN0KToKCiAgICBkZWYgX19pbml0X18oc2VsZik6CgogICAgICAgIHNlbGYucG9zID0geyd4JzoyMiwneSc6MTV9CiAgICAgICAgc2VsZi5hbmNob3IgPSB7J3gnOjEsJ3knOjMzfQoKICAgIGRlZiBkb2l0KHNlbGYpOgoKICAgICAgICB4ID0gc2VsZi5wb3NbJ3gnXStzZWxmLmFuY2hvclsneCddCiAgICAgICAgeSA9IHNlbGYucG9zWyd5J10rc2VsZi5hbmNob3JbJ3knXQoKCmNsYXNzIExMKG9iamVjdCk6CgogICAgZGVmIF9faW5pdF9fKHNlbGYpOgoKICAgICAgICBzZWxmLmwgPSBbMjIsMTUsMSwzM10KCiAgICBkZWYgZG9pdChzZWxmKToKCiAgICAgICAgeCA9IHNlbGYubFswXStzZWxmLmxbMl0KICAgICAgICB5ID0gc2VsZi5sWzFdK3NlbGYubFszXQoKCmNsYXNzIEwob2JqZWN0KToKCiAgICBkZWYgX19pbml0X18oc2VsZik6CgogICAgICAgIHNlbGYucG9zID0gWzIyLDE1XQogICAgICAgIHNlbGYuYW5jaG9yID0gWzEsMzNdCgogICAgZGVmIGRvaXQoc2VsZik6CgogICAgICAgIHggPSBzZWxmLnBvc1swXStzZWxmLmFuY2hvclswXQogICAgICAgIHkgPSBzZWxmLnBvc1sxXStzZWxmLmFuY2hvclsxXQoKCmNsYXNzIFQob2JqZWN0KToKCiAgICBkZWYgX19pbml0X18oc2VsZik6CgogICAgICAgIHNlbGYucG9zID0gKDIyLDE1KQogICAgICAgIHNlbGYuYW5jaG9yID0gKDEsMzMpCgogICAgZGVmIGRvaXQoc2VsZik6CgogICAgICAgIHggPSBzZWxmLnBvc1swXStzZWxmLmFuY2hvclswXQogICAgICAgIHkgPSBzZWxmLnBvc1sxXStzZWxmLmFuY2hvclsxXQoKCmNsYXNzIFYob2JqZWN0KToKCiAgICBkZWYgX19pbml0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