Python object overhead?
mark at freelance-developer.com
Sat Mar 24 00:31:17 CET 2007
On Fri, 23 Mar 2007 19:11:23 -0300, Gabriel Genellina wrote:
> Poor xreadlines method had a short life: it was born on Python 2.1 and got
> deprecated on 2.3 :(
> A file is now its own line iterator:
> f = open(...)
> for line in f:
Thanks for pointing that out! I had completely forgotten about
I've tested them before. readlines() is very slow. The deprecated
xreadlines() is close in speed to open() as an iterator. In my particular
test, I found the following:
readlines() -> 32 "time units"
xreadlines() -> 0.7 "time units"
open() iterator -> 0.41 "time units"
Mark Nenadov -> skype: marknenadov, web: http://www.marknenadov.com
-> "They need not trust me right away simply because the British say
that I am O.K.; but they are so ridiculous. Microphones everywhere
and planted so obviously. Why, if I bend over to smell a bowl of
flowers, I scratch my nose on a microphone."
-- Tricyle (Dushko Popov) on American Intelligence
More information about the Python-list