Package grizzled :: Module misc
[hide private]
[frames] | no frames]

Module misc

source code

The grizzled.misc module contains miscellanous functions and classes that don't seem to fit well in other modules.

Classes [hide private]
  ReadOnlyObjectError
Thrown by ReadOnly to indicate an attempt to set a field.
  ReadOnly
A ReadOnly object wraps another object and prevents all the contained object's fields from being written.
Functions [hide private]
int
bitcount(num)
Count the number of bits in a numeric (integer or long) value.
source code
Variables [hide private]
  log = logging.getLogger('grizzled.misc')
  __package__ = 'grizzled'
Function Details [hide private]

bitcount(num)

source code 

Count the number of bits in a numeric (integer or long) value. This method is adapted from the Hamming Weight algorithm, described (among other places) at http://en.wikipedia.org/wiki/Hamming_weight

Works for up to 64 bits.

Parameters:
  • num (int) - The numeric value
Returns: int
The number of 1 bits in the binary representation of num