Created
May 28, 2015 12:13
-
-
Save ironhouzi/519dda3f57a322e45f36 to your computer and use it in GitHub Desktop.
Python optimization problem
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
def validWylie(self, syllable): | |
return syllable.wylie.startswith(self.ga_prefix) \ | |
or not any(char not in self.latin_set for char in syllable.wylie) | |
# called with: if not validWylie(somesyllable): ... | |
# runs at 10.7 seconds on test case |
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
def invalidWylie(self, syllable): | |
if not syllable.wylie.startswith(self.ga_prefix): | |
for c in syllable.wylie: | |
if c not in self.latin_set: | |
return True | |
return False | |
# called with: if invalidWylie(somesyllable): ... | |
# runs at 10.3 seconds on test case |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment