On Thu, 17 Mar 2016 17:47:55 +0200, Marko Rauhamaa wrote:
> Can't comment on the numbers but the code segments are not quite > analogous. What about this one: > > #!/usr/bin/env python > # vim: tw=0 > import sys > import re > > isready = re.compile("(.*) is ready") > for fn in sys.argv[1:]: > tn = None > with open(fn) as fd: > for line in fd: > match = isready.match(line) > if match: > tn = match.group(1) > elif "release_req" in line: > print tn > > > Marko I need the second check to also be a RE because it's not separate tokens. How about this change: match = isready.match (line) if match: tn = match.group(1) > continue match = relreq.match (line) if match: print tn real 0m28.737s user 0m28.538s sys 0m0.128s Shaved 2 seconds off. -- https://mail.python.org/mailman/listinfo/python-list