How to make regexes faster? (Python v. OmniMark)

Jeff Shannon jeff at ccvcorp.com
Fri Apr 19 16:29:17 EDT 2002


In article <a9pt8a$3nh$1 at peabody.colorado.edu>, 
fperez528 at yahoo.com says...
> 
> I don't know how far back (version wise) this works, but I'd rather use:
> 
> for line in sys.stdin.xreadlines():
> 
> which should be pretty good. And I guess if the name lookups aren't optimized 
> away (which I don't know) you can always do
> 
> xread = sys.stdin.xreadlines
> for line in xread():

I don't think this would be a significant savings.  As I 
understand it, the name lookup and function call only happens 
once anyhow, and returns an xreadlines object, which the for-loop 
then iterates over.  Trying to stash the bound method doesn't 
really gain anything if it's only used once.

I'd definitely prefer xreadlines() to readlines(), though.

-- 

Jeff Shannon
Technician/Programmer
Credit International



More information about the Python-list mailing list