There are very long arrays with byte-sized entries. I want to make it so that each bit from every byte becomes its own array entry.
An example of what I want to do is to manipulate the following array:
[0b00001111, 0b01010101, 0b11110000]
to get this array:
[0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0]
I know that it is possible to do this via loops but I want to see whether there is a faster method (with less time complexity) first.
I think what you mean by using loops is something like this:
Output:
You could do this in one line like this:
But if speed is your biggest concern, you should probably use numpy:
Output:
You may also want to reshape your ndarray so that each number has its own row:
Output: