Newbie tip: Prg speed from ~5 hrs to < 1 minute

Terry Byrne TerryByrne1963 at yahoo.com
Mon Apr 29 10:37:24 EDT 2002


Jochen,

Thanks for the response. 

I'm nobody in the Python world, wish I could help you with the
documentation! I agree with you that it's a good reference, but I too
didn't find it helpful as a tutorial.

To get started I read "Learning Python" by Lutz & Ascher, published by
O'Reilly (http://www.oreilly.com). Once I realized that everything in
Python corresponds to what Perl would call either a "scalar" or a
"list", things got easier! Of course, beyond that Python is truly
object-oriented in a way that Perl isn't, but that's another
discussion ;-) ...

Basically I'm going through a list of strings in the log file,
generating an HTML summary page and conditionally e-mailing certain
production managers. pass lets me treat the long list of lines like a
C switch or a Pascal case: once a certain error code is found, pass
skips to the next line in the list without even testing for the other
codes. Much faster, of course. Please see my seperate response to
Fernando in this thread.

I learned about "pass" in Beazley's "Python Essential Reference",
published by New Riders Publishing (http://www.newriders.com). Then
grepped the modules that ship with Python and observed that the Python
pros use it a lot, and figured it must be very helpful. I haven't
calculated the percentage change in a shortening of runtime from 1 1/2
hours to < a minute, but I know it's good enough for me!

-Terry

"Jochen Küpper <jochen at jochen-kuepper.de> wrote in message news:<m3y9f7hdc7.fsf at box.home.de>...
> On 27 Apr 2002 10:01:21 -0700 Terry Byrne wrote:
> 
> Thanks for your posting, but I don't understand the following:
> 
> Terry> Then I used the keyword "pass" whenever I ran an re since each
> Terry> line can contain only one error; after running an re it's not
> Terry> necessary to look for other error codes at all.
> 
> You are passing 'pass' to compile or search, or what are you doing
> here?  Is this documented anywhere?  I could neither find it in the
> manual nor the re HOWTO; maybe it's just me, though:O
> 
> Btw: An index would serve the HOWTO well:)) It is pretty hard to find
> information in there in a non-linear way (that is, without reading all
> of it over and over).  It's a nice document, but it is a little
> unorganized.
> 
> Greetings,
> Jochen



More information about the Python-list mailing list