Skip to content

Instantly share code, notes, and snippets.

@mrocklin
Created June 15, 2013 04:51
Show Gist options
  • Save mrocklin/5786945 to your computer and use it in GitHub Desktop.
Save mrocklin/5786945 to your computer and use it in GitHub Desktop.
# Benchmarks https://gist.github.com/mrocklin/5786874
from boiler import Boiler, TypedBoiler
class A(object):
__slots__ = ['a', 'b']
def __init__(self, a, b):
self.a = a
self.b = b
class B(object):
def __init__(self, a, b):
self.a = a
self.b = b
class C(Boiler):
__slots__ = ['a', 'b']
class D(TypedBoiler):
__slots__ = ['a', 'b']
__types__ = int, int
timeit A(1, 2) # 1000000 loops, best of 3: 385 ns per loop
timeit B(1, 2) # 1000000 loops, best of 3: 454 ns per loop
timeit C(1, 2) # 1000000 loops, best of 3: 1.23 us per loop
timeit D(1, 2) # 100000 loops, best of 3: 1.58 us per loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment