Python space+time efficient Data Structure to store 2D Bit Arrays
<p>I want to create a 2D Binary (Bit) Array in Python in a space and time efficient way as my 2D bitarray would be around 1 Million(rows) * 50000(columns of 0's or 1's) and also I would be performing bitwise operations over these huge elements. My array would look something like:</p>

<pre><code>0 1 0 1
1 1 1 0
1 0 0 0 
...
</code></pre>

<p>In C++ most efficient way (space) for me would be to create a kind of array of integers where each element represents 32 bits and then I can use the shift operators coupled with bit-wise operators to carry operations.</p>

<p>Now I know that there is a bitarray module in python. But I am unable to create a 2D structure using list of bit-arrays. How can I do this?</p>

<p>Another way I know in C++ would be to create a map something like <code>map&lt;id, vector&lt;int&gt; &gt;</code> where then I can manipulate the vector as I have mentioned above. Should  I use the dictionary equivalent in python?</p>

<p>Even if you suggest me some way out to use bit array for this task it will be great If I can get to know whether I can have multiple threads operate on a splice of bitarray so that I can make it multithreaded. Thanks for the help!!</p>

<p>EDIT:</p>

<p>I can even go on creating my own data structure for this if the need be. However just wanted to check before reinventing the wheel.</p>
