[Tutor] Load Entire File into memory

Amal Thomas amalthomas111 at gmail.com
Tue Nov 5 14:20:33 CET 2013


On Mon, Nov 4, 2013 at 10:00 PM, Steven D'Aprano <steve at pearwood.info>
wrote:
>

>
> import os
> filename = "YOUR FILE NAME HERE"
> print("File size:", os.stat(filename).st_size)
> f = open(filename)
> content = f.read()
> print("Length of content actually read:", len(content))
> print("Current file position:", f.tell())
> f.close()
>
>
> and send us the output.


 This is the output:
   File size: 50297501884
   Length of content actually read: 50297501884
   Current file position: 50297501884
This Code used 61.4 GB RAM and 59.6 GB swap (I had ensured that no other
important process were running in my server before running this :D)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131105/ee926d9f/attachment.html>


More information about the Tutor mailing list