title: read list of strings as file, python3
body: <p>I have a list of strings, and would like to pass this to an api that accepts only a <code>file</code>-like object, without having to concatenate/flatten the list to use the likes of <code>StringIO</code>.</p>
  <p>The strings are utf-8, don't necessarily end in newlines, and if naively concatenated could be used directly in <code>StringIO</code>.</p>
  <p>Preferred solution would be within the standard library (python3.8) (Given the shape of the data is naturally similar to a file (~identical to <code>readlines()</code> obviously), and memory access pattern would be efficient, I have a feeling I'm just failing to DuckDuckGo correctly) - but if that doesn't exist any &quot;streaming&quot; (no data concatenation) solution would suffice.</p>
  <hr />
  <p>[Update, based on @JonSG's links]</p>
  <p>Both <code>RawIOBase</code> and <code>TextIOBase</code> look provide an api that decouples arbitrarily sized &quot;chunks&quot;/fragments (in my case: strings in a list) from a <code>file-like</code> read which can specify its own read chunk size, while streaming the data itself (memory cost increases by only some window at any given time [dependent of course on behavior of your source &amp; sink])</p>
  <p><code>RawIOBase.readinto</code> looks especially promising because it provides the buffer returned to client reads directly, allowing much simpler code - but this appears to come at the cost of one full copy (into that buffer).</p>
  <p><code>TextIOBase.read()</code>  has its own cost for its operation solving the same subproblem, which is concatenating <code>k</code> (<code>k</code> much smaller than <code>N</code>) chunks together.</p>
  <p>I'll investigate both of these.</p>