0

I have a list with about 32800 elements which are all 0 or 1, so they are binary. (note 0/1 not true/false) Now I need element 0 till 31 in an integer (32bit) format, and save the values in another list. My recent try is too slow, it should take about 10ms and all I got is 600 ms.

Here is what I have so far:

while offset < length:
    data_bin1 = int(''.join(map(str, data_bin[offset:(offset+32)])), 2)

note: This should help you to get an idea of what I am looking for.

data_bin is my list with a lenght of 32800 elements formated like this

data_bin=
    [0,0,1,0,1,0,1,1,
     0,0,1,1,0,1,0,1,
     0,0,1,0,1,1,0,1,  
     0,0,1,1,0,0,1,1,
     .... n]

     -> 00101011001101010010110100110011 = 724905267

What I need is to take bit 0 till 31, convert them into an int32 value and likely append them to another list or better in a queue.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
InvAdErZz
  • 49
  • 1
  • 11
  • 1
    "It should take about 10ms" based on what evidence? – Kyle Pittman Oct 07 '15 at 17:28
  • @ Monkey I am calculating image data. So if a frame needs about 600ms there is no chance for me to get my 60F/s. Yes, logically it could take about 16ms.. but it's not the only thing the program has to work on. – InvAdErZz Oct 07 '15 at 17:36

0 Answers0