Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32169 > unrolled thread

bit count or bit set && Python3

Started byCharles Hixson <charleshixsn@earthlink.net>
First post2012-10-24 19:19 -0700
Last post2012-10-24 19:19 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  bit count or bit set && Python3 Charles Hixson <charleshixsn@earthlink.net> - 2012-10-24 19:19 -0700

#32169 — bit count or bit set && Python3

FromCharles Hixson <charleshixsn@earthlink.net>
Date2012-10-24 19:19 -0700
Subjectbit count or bit set && Python3
Message-ID<mailman.2869.1351200329.27098.python-list@python.org>
In Python3 is there any good way to count the number of on bits in an 
integer (after an & operation)?
Alternatively, is there any VERY light-weight implementation of a bit 
set?  I'd prefer to use integers, as I'm probably going to need 
thousands of these, if the tests work out.  But before I can test, I 
need a decent bit counter.  (shift, xor, &, and | are already present 
for integer values, but I also need to count the number of "true" items 
after the logical operation.  So if a bitset is the correct approach, 
I'll need it to implement those operations, or their equivalents in 
terms of union and intersection.)

Or do I need to drop into C for this?

-- 
Charles Hixson

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web