Speed problems with Python vs. Perl
Carlos Alberto Reis Ribeiro
cribeiro at mail.inet.com.br
Wed Mar 28 12:33:48 EST 2001
At 15:37 28/03/01 +0000, Fredrik Lundh wrote:
>for a backwards-compatible version of xreadlines, use
>the double-loop pattern from:
>
>http://effbot.org/guides/readline-performance.htm
Looking at your code there, a saw readline-example-3.py:
# readline-example-3.py
file = open("sample.txt")
while 1:
lines = file.readlines(100000)
if not lines:
break
for line in lines:
pass # do something
Then I got to the library reference manual:
readlines ([sizehint])
Read until EOF using readline() and return a list containing the
lines thus read. If the optional sizehint argument is present,
instead of reading up to EOF, whole lines totalling approximately
sizehint bytes (possibly after rounding up to an internal buffer
size) are read. Objects implementing a file-like interface may choose
to ignore sizehint if it cannot be implemented, or cannot be
implemented efficiently.
I think that this must be new on Python 2.0; I really dont remember it from
my 1.5.2 days (maybe I overlooked it). So I have two questions:
1) What platforms do implement this? DO I need to check the code to have
this information?
2) There is any documentation about buffer sizes for different platforms?
Carlos Ribeiro
More information about the Python-list
mailing list