Last active
September 26, 2016 11:23
-
-
Save Tukki/670be24c7b21cb3fbed717b673799a42 to your computer and use it in GitHub Desktop.
python setattr test
This file contains hidden or 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
# _*_ coding: utf-8 _*_ | |
# http://stackoverflow.com/questions/12798653/does-setattr-and-getattr-slow-down-the-speed-dramatically | |
# run: time python setattr_test.py | |
class O(object): | |
pass | |
o = O() | |
for i in xrange(10000000): | |
setattr(o, 'a', 1) # python setattr_test.py 1.44s user 0.01s system 99% cpu 1.449 total | |
#o.a = 1 # python setattr_test.py 0.68s user 0.00s system 99% cpu 0.686 total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment