title: Efficient Way to Read File Byte by Byte and Convert to Int Array?
body: <p>I'm trying to read in a PDF source file, and append each individual byte to an array of 8-bit integers. This is the slowest function in my program, and I was wondering if there was a more efficient method to do so, or if my process is completely wrong and I should go about it another way. Thanks in advance!</p>
  
  <pre><code>pagesize = 4096
  arr = []
  doc = ""
  with open(filename, 'rb') as f:
      while doc != b'':
          doc = f.read(pagesize)
          for b in doc:
              arr.append(b)
  </code></pre>