Skip to content

Instantly share code, notes, and snippets.

@startakovsky
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save startakovsky/7d3648211540bcea0e76 to your computer and use it in GitHub Desktop.
Save startakovsky/7d3648211540bcea0e76 to your computer and use it in GitHub Desktop.
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)
def mysql_bit_to_bool(value):
"""Return Python [an array of] boolean values."""
mysql_bits = {'\x01': True, '\x00': False}
return mysql_bits[value]
@startakovsky
Copy link
Author

Which one is better? Is it ever advantageous from a performance perspective to "vectorize" a function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment