[Tutor] how to extract data only after a certain condition is met

Emile van Sebille emile at fenx.com
Wed Oct 6 21:10:24 CEST 2010


On 10/6/2010 11:58 AM Joel Goldstick said...
> On Wed, Oct 6, 2010 at 2:50 PM, Emile van Sebille<emile at fenx.com>  wrote:
>
>> On 10/6/2010 9:25 AM Eduardo Vieira said...
>> <snip>
>>
>>
>>   Of course this solution is simpler:
>>> extracted = a[a.index("i")+1:]
>>> But I didn't want to build a list in memory with "readlines()" in the
>>> case of a file.
>>>
>>
>> This is what I do unless the files are _really big_
>>
>> For-me-really-big-is-over-200Mb-ish-ly y'rs,
>>
>> Emile
>>
> Why not loop with readline() and then the slice.  That way only one line at
> time in memory
>

Because I'd consider that a premature optimization.  I don't commonly 
worry about managing the memory footprint until there's a reason to. 
I've found that you can work to minimize the footprint, but as it's 
often indeterminate, you can't really control it.  So I don't.

Emile



More information about the Tutor mailing list