By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

bz2.readline() slow ?

P: n/a
Dear all,

I am a bit puzzled, as

-----snip-----
import bz2
f=bz2.BZ2File('data/data.bz2');

while f.readline():
pass
-----snip-----

takes twice the time (10 seconds) to read/decode a bz2 file
compared to

-----snip-----
import bz2
f=bz2.BZ2File('data/data.bz2');
x=f.readlines()
-----snip-----

(5 seconds). This is even more strange as the help(bz2) says:

| readlines(...)
| readlines([size]) -list
|
| Call readline() repeatedly and return a list of lines read.
| The optional size argument, if given, is an approximate bound on the
| total number of bytes in the lines returned.

This happens on python2.3 - python2.5 and it does not help to specify a
maximum line size.

Any ideas ?
Soeren
Nov 24 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.