PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed Need Money Easy and Quick?

Re: Python object overhead?

 List
Subject: Re: Python object overhead?
Poster: MarkNenadovmark@freelance-developer.com
Date: Fri, 23 Mar 2007 17:27:25 -0400
Related Postings: 1 2 3 4 5 6 7
On Fri, 23 Mar 2007 15:11:35 -0600, Matt Garman wrote:


>
> Is this "just the way it is" or am I overlooking something obvious?
>

Matt,

If you iterate over even the smallest object instantiation a large amount of times, it will be costly compared to a simple list append.

I don't think you can get around some overhead with the objects.

However, in terms of generally efficiency not specifically related to object instantiation, you should look into xreadlines().

I'd suggest doing the following instead of that while loop:

for line in open(sys.argv[1]).xreadlines(): ..

-- Mark Nenadov -> skype: marknenadov, web: http://www.marknenadov.com -> "Glory is fleeting, but obscurity is forever." -- Napoleon Bonapart

 

Page2Go2.com is not responsible for content of this message.