I want to create a two-dimensional binary (bit) array in Python in effective space and time, since my 2D bitarray will be about 1 million (rows) * 50,000 (columns 0 or 1), and I will also perform bitwise operations on these huge elements . My array will look something like this:
0 1 0 1 1 1 1 0 1 0 0 0 ...
In C ++, the most efficient way (space) for me would be to create a kind of array of integers, where each element is 32 bits, and then I can use shift operators in combination with bitwise operators to transfer operations.
Now I know that in python there is a bitarray module. But I cannot create a 2D structure using a list of bit arrays. How can i do this?
Another way I know in C ++ would be to create a map similar to map<id, vector<int> >
, where I can manipulate a vector, as I mentioned above. Should I use the dictionary equivalent in python?
Even if you offer me some way to use a bitmap for this task, it will be great. If I can find out if I can have multiple streams for splicing a bitarray so that I can make it multithreaded. Thanks for the help!
EDIT:
I can even start creating my own data structure for this, if necessary. However, I just wanted to check before inventing the wheel.
Yavar source share