title: How to convert a string representation of bytearray to a numpy array?
body: <p>I have a string like this:</p>
  <pre><code>string = &quot;b'\\xf4\\xf0\\xf2\\xef\\xf8\\xf2\\xee'&quot;
  </code></pre>
  <p>So far I have come up with this:</p>
  <pre><code>arr = np.array([int(s_num, 16) for s_num in re.findall(r'x([a-f0-9]{2})', string)], dtype=np.uint8)
  </code></pre>
  <p>For large strings this gets really slow. What is the best way to convert the string to a numpy array (of data type <code>np.uint8</code>)? Thanks.</p>