[issue29882] Add an efficient popcount method for integers
Mark Dickinson
report at bugs.python.org
Sun May 31 09:46:50 EDT 2020
Mark Dickinson <dickinsm at gmail.com> added the comment:
A couple of other data points:
- Swift has nonzeroBitCount: https://developer.apple.com/documentation/swift/int/2886050-nonzerobitcount
- Rust has count_ones: https://doc.rust-lang.org/std/primitive.u64.html
- Go's math/bits package has OnesCount
- The closest thing in Mathematica appears to be DigitCount, which isn't base-specific.
@Mark Shannon: what name would you suggest, and why? The term "population count" feels too non-obvious and specialist to me, and anything involving "Hamming" likewise.
"count_ones" isn't obviously a bit operation.
"count_set_bits"?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29882>
_______________________________________
More information about the Python-bugs-list
mailing list