Saturday, October 4, 2014

Initializing Dictionary Elements Inside A Loop - Python

There's a really interesting tip in the "Initializing Dictionary Elements" section of this page: https://wiki.python.org/moin/PythonSpeed/PerformanceTips

"it is cheaper to use a try statement" when checking to see if a key exists in a dictionary (inside of a loop).

No comments:

Post a Comment