This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients fredrikj, loewis, mark.dickinson, pitrou, rhettinger, skip.montanaro, terry.reedy, vstinner
Date 2008-12-16.19:41:47
SpamBayes Score 0.00010895525
Marked as misclassified No
Message-id <1229456513.77.0.266207058851.issue3439@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for all the comments.  Here's an updated patch, with quite a few 
changes:

code:
 - drop lookup tables in favour of "while(x) {x >>= 1; count += 1;}"
 - add example to docstring, and use PyDoc_STRVAR macro for docstrings

docs:
 - add "bin(37)" to whatsnew example
 - move main documentation out of the bit operations table into its own
   subsection, so that it can be indexed properly.
 - expand main documentation with examples, informal definition,
   equivalent Python code
 - I dropped the 1 + math.floor(...) definition from the docs, judging
   that 1 informal, 1 formal and 1 Python definition should be enough.

tests:
 - as proposed by Raymond, directly check equivalence with formal
   definition, equivalent Python code, and two other possible definitions.

(FWIW I prefer 'x>>1' over 'x//2' in the Python code, because it's more 
immediately related to the intended sense:  the operation should be 
thought of as a bit shift rather than a division.)
History
Date User Action Args
2008-12-16 19:41:53mark.dickinsonsetrecipients: + mark.dickinson, loewis, skip.montanaro, rhettinger, terry.reedy, pitrou, vstinner, fredrikj
2008-12-16 19:41:53mark.dickinsonsetmessageid: <1229456513.77.0.266207058851.issue3439@psf.upfronthosting.co.za>
2008-12-16 19:41:52mark.dickinsonlinkissue3439 messages
2008-12-16 19:41:51mark.dickinsoncreate