Last active
August 29, 2015 14:26
-
-
Save startakovsky/7d3648211540bcea0e76 to your computer and use it in GitHub Desktop.
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
from numpy import vectorize | |
def mysql_bit_to_bool(values): | |
"""Return Python [an array of] boolean values.""" | |
mysql_bits = {'\x01': True, '\x00': False} | |
def wrapper(value): | |
return mysql_bits[value] | |
return vectorize(wrapper)(values) |
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
def mysql_bit_to_bool(value): | |
"""Return Python [an array of] boolean values.""" | |
mysql_bits = {'\x01': True, '\x00': False} | |
return mysql_bits[value] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which one is better? Is it ever advantageous from a performance perspective to "vectorize" a function?