This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author smurf
Recipients
Date 2002-03-19.17:37:20
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=10327

I'm in favor for the "let files be their own iterator and set .next equal to .readline" solution. The above example can _really_ bite you.

The current xreadlinesmodule.c could be converted to a standalone module, if it really is necessary to optimize.

The trivial solution for this problem is to change CHUNKSIZE (in Modules/xreadlinesmodule) to 1. Or, even better, to convert it into an instance variable, so you can do this:

f=open(...)
fi=f.iter(chunk=2000)
for line in fi:
    ...

if you want speed, or just write

for line in f:

(which internally converts to f.iter(chunk=1))

if you want safety.

I'm not too firm with Python C interfacing, otherwise I'd write a patch... any takers?
History
Date User Action Args
2007-08-23 13:59:33adminlinkissue524804 messages
2007-08-23 13:59:33admincreate