title: Opitimizing 2 functions written in Python
body: <p>I would like to decrease the time complexity of this function. When I have like 1020 KB, it takes a few seconds to complete these functions. The example of input is <code>[&quot;1001010&quot;, &quot;1000001&quot;]</code></p>
  <pre><code>def bits_to_rgb(data):
      bits = [255 if x == &quot;1&quot; else 0 for x in ''.join(data)]
      full_bits = []
  
      for i in bits:
           full_bits.extend([i, i, i])
  
      return full_bits
  </code></pre>
  <p>output</p>
  <pre><code>rgb = bits_to_rgb([&quot;1001010&quot;, &quot;1000001&quot;])
  rgb
  &gt;&gt; [255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255]
  </code></pre>
  <p>As I said I would like to decrease the time complexity. I tried to yield the result and then call <code>list()</code> later on but the time difference was not significant.</p>