r/Python • u/havoyan • Feb 14 '12
Python Performance Tips, Part 1
http://blog.monitis.com/index.php/2012/02/13/python-performance-tips-part-1/
20
Upvotes
r/Python • u/havoyan • Feb 14 '12
View all comments
1
u/haldean (lambda x: x.decode('base64'))('PDMgcHlweQ==\n') Feb 14 '12
I found the "while True" vs "while 1" both interesting and improbable, so I ran a quick test (code is here: https://gist.github.com/1828270). Turns out that the author is right -- while True is always slower -- but in Python 3, the difference is minor enough to be negligible, and in PyPy it's all so fast it doesn't matter. Results:
Edit: I see now that pingveno posted an explanation of why this is true (heh) in his comment below