Last active
April 25, 2016 01:55
-
-
Save timothycrosley/ddd4c07d1312831207b8d3381ff44f12 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
%cpaste | |
import time | |
class Test(object): | |
__slots__ = ('a', 'b', 'c') | |
def __init__(self): | |
self.a = 1 | |
self.b = 1 | |
self.c = 1 | |
class Test2(object): | |
temp = Test() | |
temp2 = Test() | |
temp3 = Test() | |
start = time.time() | |
for x in xrange(1000000000): | |
Test2() | |
print("With slots:{0}".format(time.time() - start)) | |
-- | |
%cpaste | |
import time | |
class Test(object): | |
#__slots__ = ('a', 'b', 'c') | |
def __init__(self): | |
self.a = 1 | |
self.b = 1 | |
self.c = 1 | |
class Test2(object): | |
temp = Test() | |
temp2 = Test() | |
temp3 = Test() | |
start = time.time() | |
for x in xrange(1000000000): | |
Test2() | |
print("Without slots:{0}".format(time.time() - start)) | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment