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
# Comparison of LBYL versus EAFP | |
# http://www.reddit.com/r/Python/comments/pou99/python_performance_tips_part_1/ | |
from __future__ import print_function | |
from hashlib import md5 | |
_lbyl_cache = {} | |
_eafp_cache = {} | |
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
# Noughts and crosses for Python 2 | |
# http://www.reddit.com/r/learnpython/comments/oxgr0/converting_to_and_from_ternary/ | |
# Winning positions, represented as bit masks | |
wins = [ | |
'111 000 000', '000 111 000', '000 000 111', # Across | |
'100 100 100', '010 010 010', '001 001 001', # Down | |
'100 010 001', '001 010 100', # Diagonal | |
] | |
# Store winning boards as integers |
NewerOlder