[FEEDBACK] Is this script efficient...is there a better way?

Sean 'Shaleh' Perry shalehperry at attbi.com
Thu Sep 12 07:26:53 CEST 2002


On Wednesday 11 September 2002 19:08, Michael Schneider wrote:
> Bob X wrote:
> >> 1) readlines() loads the entire file into a list so if you have a 30+
> >> mb file you just ate 30+mb of memory.  Try using xreadlines()
> >> instead, it reads the file line by line and is much more memory
> >> friendly.
> >
> > Very cool...I had missed that!
>
> It is much slower though.  I am not sure about your config, but I am
> running with a Gig of memory.
> I would much rather have the speed then the  30 mb of memory.  Again,
> check your config.

sorry, I am not used to my program being the only piece of software running on 
a system.  Sure his app may only use 30mb out of a 512mb system.  But how 
many other apps are coded just like his and believe all of the machine's 
memory can be used up by one program.  Every time I have made that choice I 
have had to go back and change it.  Plus this allows for the file to not be a 
file anymore.




More information about the Python-list mailing list