title: Convert/Write PDF to RAM as file-like object for further working with it
body: <p>My script generates PDF (<code>PyPDF2.pdf.PdfFileWriter object</code>) and stores it in the variable.
  I need to work with it as <code>file-like object</code> further in script. But now I have to write it to HDD first. Then I have to open it as file to work with it.</p>
  
  <p>To prevent this unnecessary writing/reading operations I found many solutions - <code>StringIO</code>, <code>BytesIO</code> and so on. But I cannot find what exactly can help me in my case.</p>
  
  <p>As far as I understand - I need to "convert" (or write to RAM) <code>PyPDF2.pdf.PdfFileWriter object</code> to <code>file-like object</code> to work directly with it.</p>
  
  <p>Or there is another method that fits exactly to my case?</p>
  
  <p><strong>UPDATE - here is code-sample</strong></p>
  
  <pre><code>from pdfrw import PdfReader, PdfWriter, PageMerge
  from PyPDF2 import PdfFileReader, PdfFileWriter
  
  
  red_file = PdfFileReader(open("file_name.pdf", 'rb'))
  
  large_pages_indexes = [1, 7, 9]
  
  large = PdfFileWriter()
  for i in large_pages_indexes:
      p = red_file.getPage(i)
      large.addPage(p)
  
  # here final data have to be written (I would like to avoid that)
  with open("virtual_file.pdf", 'wb') as tmp:
    large.write(tmp)
  
  # here I need to read exported "virtual_file.pdf" (I would like to avoid that too)
  with open("virtual_file.pdf", 'rb') as tmp:
    pdf = PdfReader(tmp) # here I'm starting to work with this file using another module "pdfrw"
    print(pdf)
  </code></pre>