how long a Str can be used in this python code segment?
Gary Herron
gherron at islandtraining.com
Mon Feb 1 04:29:20 EST 2010
Stephen.Wu wrote:
> tmp=file.read() (very huge file)
> if targetStr in tmp:
> print "find it"
> else:
> print "not find"
> file.close()
>
> I checked if file.read() is huge to some extend, it doesn't work, but
> could any give me some certain information on this prolbem?
>
>
Python has no specific limit on string size other than memory size and
perhaps 32 bit address space and so on. However, if your file size is
even a fraction of that size, you should not attempt to read it all into
memory at once. Is there not a way to process your file in batches of a
reasonable size?
Gary Herron
More information about the Python-list
mailing list