Created
June 15, 2013 04:51
-
-
Save mrocklin/5786945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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