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: BjoernSchliessmannusenet-mail-0306.20.chr0n0ss@spamgourmet.com
Date: Sat, 24 Mar 2007 01:36:22 +0100
Related Postings: 1 2 3 4 5 6 7
Matt Garman wrote:


> Since each line corresponds to a record, what I'm trying to do is
> create an object from each record. However, it seems that doing
> this causes the memory overhead to go up two or three times.

(Note that almost everything in Python is an object!)


> Example 1: read lines into list:
> # begin readlines.py
> import sys, time
> filedata = list()
> file = open(sys.argv[1])
> while True:
> line = file.readline()
> if len(line) == 0: break # EOF

"one blank line" == "EOF"? That's strange. Intended?

The most common form for this would be "if not line: (do something)".


> Example 2: read lines into objects:
> # begin readobjects.py
> import sys, time
> class FileRecord:
> def __init__(self, line):
> self.line = line

What's this class intended to do?

Regards,

Björn

-- BOFH excuse #1:

clock speed

 

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