Skip to content

Instantly share code, notes, and snippets.

@KrzysztofCiba
Created June 9, 2013 19:54
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 KrzysztofCiba/5744958 to your computer and use it in GitHub Desktop.
Save KrzysztofCiba/5744958 to your computer and use it in GitHub Desktop.
popcnt16k.py
__bc16b = [ 0 ] * (256*256)
for i in range(256*256):
__bc16b[i] = ( i & 1 ) + __bc16b[i/2]
def popcnt16b( arg ):
""" popcnt using 16bits loom up table """
return sum( [ __bc16b[( arg >> i ) & 65535 ] for i in range( 0, arg.bit_length(), 16 ) ] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment