Posted By

efi on 09/06/12


Tagged


Versions (?)

reportlab low performance


 / Published in: Python
 

So, when I try to set the BYTESTOREAD variable to more than 200-300 thousands (i.e., just to see what happening, not reading the full book, just some part of it) - it takes HUGE amount of time...

  1. BYTES_TO_READ = 10000
  2.  
  3. def go(text):
  4. doc = SimpleDocTemplate("output.pdf")
  5. Story = [Spacer(1, 2*inch)]
  6. style = styles["Normal"]
  7. p = Paragraph(text, style)
  8. Story.append(p)
  9. doc.build(Story)
  10.  
  11. def get_text_from_file():
  12. source_file = open("book.txt", "r")
  13. text = source_file.read(BYTES_TO_READ)
  14. source_file.close()
  15. return text
  16.  
  17. go(get_text_from_file())

Report this snippet  

You need to login to post a comment.