From: Noel O'B. <bao...@gm...> - 2007-02-02 11:57:49
|
On 02/02/07, Karol Langner <kar...@kn...> wrote: > Thanks... it might be worthwhile to move some more things to LogFile.pares, > but I need your input on these. > > 1) The stuff before the loop (inputfile.seek, initialize self.progress, > etc.). For this, inputfile, nstep, and oldstep would need to be attributes of > the class. However, since they are temporary (parsing is never aborted before > it's finished, I think), this may not be a good idea. Do they have to be attributes of the class? Can they be local variables in parse() which are passed into extract() (or maybe this is too messy)? Alternatively, they can be 'weak' attributes, with names like self._nstep. AFAIK, this is a convention to indicate 'private' variables of a class, although it doesn't do much else. > 2) The code that uses cupdate, fupdate, nstep, and oldstep (condition "if > self.progress and random.random() < fupdate") is repeated multiple times, but > the same question arises as the above. Well, I think that this code can be moved into a function. > Could you perhaps explain the full purpose of LogFile.progress? It's main purpose is for GUI applications to be able to display a progress bar showing how near to completion the parsing is. This is because parsing can take more than 20 seconds for large files containing population data (which is what both myself and Adam were interested in). You should try out PyMOlyze to see this in action. There is some cost in seconds in including the progress code, but blindingly fast parsing is not the main goal of cclib. For instance, it is possible to rewrite our multiple 'if' statements in other forms that would parse large files quicker. If you care about this, it might be worth thinking about, bearing in mind that "premature optimization is the root of all evil" or something. > Maybe there > would be some advantages in making the logfile file object an attribute of > LogFile (as in self.intputfile)? IMO the fewer attributes the better. Since it's a 'derived attribute' (i.e. it can be recreated from self.filename), and is only used within extract(), I don't see how it can be useful. If you can think of a useful reason for doing this though, go ahead. > Karol > > -- > written by Karol Langner > Fri Feb 2 12:21:24 CET 2007 > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier. > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > cclib-devel mailing list > ccl...@li... > https://lists.sourceforge.net/lists/listinfo/cclib-devel > |