Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python equivalent to Java's BitSet

Is there a Python class or module that implements a structure that is similar to the BitSet?

like image 682
Mantas Vidutis Avatar asked Oct 15 '10 20:10

Mantas Vidutis


People also ask

Is there BitSet in Python?

A Python interface to the fast bitsets in Sage. Bitsets are fast binary sets that store elements by toggling bits in an array of numbers. A bitset can store values between 0 and capacity - 1 , inclusive (where capacity is finite, but arbitrary).

Is BitSet a data structure?

A bit array (also known as bit map, bit set, bit string, or bit vector) is an array data structure that compactly stores bits. It can be used to implement a simple set data structure.

What is the type of BitSet?

Bitset represents a fixed-size sequence of N bits and stores values either 0 or 1. Zero means value is false or bit is unset and one means value is true or bit is set. Bitset class emulates space efficient array of boolean values, where each element occupies only one bit.


1 Answers

There's nothing in the standard library. Try:

http://pypi.python.org/pypi/bitarray

like image 70
Glenn Maynard Avatar answered Oct 06 '22 11:10

Glenn Maynard