Skip to content

Instantly share code, notes, and snippets.

@dcrosta
Created June 5, 2015 13:59
Show Gist options
  • Save dcrosta/4690ee6570c69e0117f9 to your computer and use it in GitHub Desktop.
Save dcrosta/4690ee6570c69e0117f9 to your computer and use it in GitHub Desktop.
import random
class Foo(object):
def __init__(self, a, b):
self.a = a
self.b = b
foos = [
Foo(random.randint(0, 100), random.randint(100, 1000))
for _ in xrange(10000)
]
def d(a_foo):
return a_foo.a + a_foo.b
def g(a_foo):
return getattr(a_foo, "a") + getattr(a_foo, "b")
for _ in xrange(10000):
for a_foo in foos:
d(a_foo)
g(a_foo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment