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 stutzbach
Recipients belopolsky, draghuram, mark.dickinson, rhettinger, stutzbach
Date 2010-05-12.15:36:33
SpamBayes Score 3.623369e-05
Marked as misclassified No
Message-id <1273678597.41.0.607321997508.issue8692@psf.upfronthosting.co.za>
In-reply-to
Content
Thank you both for the valuable feedback.  I'm working on a revised patch that incorporates your many suggestions.

I decided to use an iterative version for two reasons:
- the reference has a note at the bottom in a tiny font suggesting it
- I found it counter-intuitive to implement product() as a recursive function.  I had a much easier time matching the code up with the formula when it was implemented iteratively.

I agree that my use of log2() was an ugly hack. ;-)  I'll fix that.

Would it be worthwhile to create a pybits.h and .c that defines _Py_FindLastSetBit and _Py_CountSetBits? (with appropriate logic in the .h and configure.in to use system/compiler versions if available)

There are already two implementations of find-last-set-bit in Python: 
bits_in_digit() in Objects/longobject.c and hi0bits() in Python/dtoa.c.  It would be nice to consolidate them.

(hi0bits counts the leading 0 bits which is a trivial transformation of finding the highest set bit)

I don't know of anyplace else in Python that needs count-set-bits.
History
Date User Action Args
2010-05-12 15:36:37stutzbachsetrecipients: + stutzbach, rhettinger, mark.dickinson, belopolsky, draghuram
2010-05-12 15:36:37stutzbachsetmessageid: <1273678597.41.0.607321997508.issue8692@psf.upfronthosting.co.za>
2010-05-12 15:36:36stutzbachlinkissue8692 messages
2010-05-12 15:36:34stutzbachcreate