Re: python reading file memory cost

2011-08-02 Thread Thomas Jollans
.@web.de] > Sent: Tuesday, August 02, 2011 4:26 PM > To: python-list@python.org > Subject: Re: python reading file memory cost > > Chris Rebert wrote: > >>> The running result was that read a 500M file consume almost 2GB RAM, >>> I cannot figure it out, somebod

RE: python reading file memory cost

2011-08-02 Thread 张彤
Subject: Re: python reading file memory cost Chris Rebert wrote: >> The running result was that read a 500M file consume almost 2GB RAM, >> I cannot figure it out, somebody help! > > If you could store the floats themselves, rather than their string > representations, tha

Re: python reading file memory cost

2011-08-02 Thread Peter Otten
Chris Rebert wrote: >> The running result was that read a 500M file consume almost 2GB RAM, I >> cannot figure it out, somebody help! > > If you could store the floats themselves, rather than their string > representations, that would be more space-efficient. You could then > also use the `array`

Re: python reading file memory cost

2011-08-01 Thread Chris Rebert
On Mon, Aug 1, 2011 at 8:22 PM, Tony Zhang wrote: > Thanks! > > Actually, I used .readline() to parse file line by line, because I need > to find out the start position to extract data into list, and the end > point to pause extracting, then repeat until the end of file. > My file to read is forma

Re: python reading file memory cost

2011-08-01 Thread Dan Stromberg
You could try forcing a garbage collection... On Mon, Aug 1, 2011 at 8:22 PM, Tony Zhang wrote: > Thanks! > > Actually, I used .readline() to parse file line by line, because I need > to find out the start position to extract data into list, and the end > point to pause extracting, then repeat u

Re: python reading file memory cost

2011-08-01 Thread Tony Zhang
Thanks! Actually, I used .readline() to parse file line by line, because I need to find out the start position to extract data into list, and the end point to pause extracting, then repeat until the end of file. My file to read is formatted like this: blabla...useless useless... /sign/ data

Re: python reading file memory cost

2011-08-01 Thread Dan Stromberg
A code snippet would work wonders in making sure you've communicated what you really need, or at least what you have now. But if you read the data into one big string, that'll be much more efficient than if you read it as a list of integers or even as a list of lines. Processing the data one chun

Re: python reading file memory cost

2011-08-01 Thread Thomas Jollans
On 01/08/11 17:05, Tong Zhang wrote: > Hello, everyone! > > > > I am trying to read a little big txt file (~1 GB) by python2.7, what I > want to do is to read these data into a array, meanwhile, I monitor the > memory cost, I found that it cost more than 6 GB RAM! So I have two > questions: >