[Mumps2Py:] [159] a bit of a performance enhancement from converting all instances of: pos = pos + x to: pos += x |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
Revision: 159
Author: pgallot
Date: 2008-03-08 14:30:02 +0000 (Sat, 08 Mar 2008)
Log Message:
-----------
a bit of a performance enhancement from converting all instances of: pos = pos + x to: pos += x
Modified Paths:
--------------
trunk/mumps2py/mumps2tok.py
Modified: trunk/mumps2py/mumps2tok.py
===================================================================
--- trunk/mumps2py/mumps2tok.py 2008-03-07 16:01:34 UTC (rev 158)
+++ trunk/mumps2py/mumps2tok.py 2008-03-08 14:30:02 UTC (rev 159)
@@ -74,19 +74,19 @@
pass_by_ref = False
if line[pos] == '.' and not MUMPS_RE_DICT['num'].match(line, pos):
pass_by_ref = True
- pos = pos + 1
+ pos += 1
exprtok = parse_expr(line, pos, r"([:,)])")
if pass_by_ref:
exprtok.pass_by_ref = True
actuallist.append(exprtok)
pos = exprtok.end
if line[pos] == ":":
- pos = pos + 1
+ pos += 1
condtok = exprtok
exprtok = parse_expr(line, pos, r"[,)]")
exprtok.post_condition(condtok)
elif line[pos] == ",":
- pos = pos + 1
+ pos += 1
return (pos + 1, actuallist)
def parse_entry_ref(line, pos):
@@ -121,7 +121,7 @@
token.offset = offset
pos = offset.end
if not MUMPS_RE_DICT["cmdEnd"].match(line, pos) and line[pos] == '^':
- pos = pos + 1
+ pos += 1
m_name = re_name.match(line, pos)
if not m_name:
routine = parse_expr(line, pos, r"([ ),(:]|\s*$)")
@@ -201,8 +201,8 @@
(sub_pat, pos) = consume_pattern(line, pos)
sub_token.params.append(sub_pat)
if line[pos] == ",":
- pos = pos + 1
- pos = pos + 1
+ pos += 1
+ pos += 1
else:
sub_token.pat_code = atom.group("patcode")
pos = atom.end()
@@ -225,11 +225,11 @@
len_line = len(line)
while pos < len_line:
if line[pos] != '"':
- pos = pos + 1
+ pos += 1
elif (pos + 1) < len_line and line[pos + 1] == '"':
- pos = pos + 2
+ pos += 2
else:
- pos = pos + 1
+ pos += 1
break
token.val = line[startpos:pos]
return (token, pos)
@@ -289,7 +289,7 @@
token.dummy = dummy
pos = dummy.end
- pos = pos + 1
+ pos += 1
mobj2 = MUMPS_RE_DICT["var"].match(line, pos)
token.varname = mobj2.group("var")
pos = mobj2.end("var")
@@ -418,7 +418,7 @@
exprtok.post_condition(condtok)
pos = condtok.end
if line[pos] == ",":
- pos = pos + 1
+ pos += 1
expr_list.append(exprtok)
parent_tok.Xecute = expr_list
@@ -431,10 +431,10 @@
while not mterminated.match(line, pos):
if line[pos] == '!':
sub_token = Token(FCC_NEWLINE, pos)
- pos = pos + 1
+ pos += 1
elif line[pos] == '#':
sub_token = Token(FCC_NEWPAGE, pos)
- pos = pos + 1
+ pos += 1
elif line[pos] == '?':
sub_token = Token(FCC_MOV, pos)
offset = parse_expr(line, pos + 1, r"([, ]|\s*$)")
@@ -448,7 +448,7 @@
sub_token = parse_expr(line, pos, r"([, ]|\s*$)")
pos = sub_token.end
if line[pos] == ',':
- pos = pos + 1
+ pos += 1
write_list.append(sub_token)
parent_tok.write_list = write_list
@@ -465,13 +465,13 @@
pos = keyword.end
expressions = []
while not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
expr = parse_expr(line, pos, r"([:, ]|\s*$)")
pos = expr.end
expressions.append(expr)
item["expressions"] = expressions
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
keyword_items.append(item)
parent_tok.keyword_items = keyword_items
@@ -484,22 +484,22 @@
while not mterminated.match(line, pos):
var = {}
if line[pos] == '(':
- pos = pos + 1
+ pos += 1
var_list = []
while line[pos] != ")":
varname = parse_expr(line, pos, r"([,)])")
var_list.append(varname)
pos = varname.end
if line[pos] == ',':
- pos = pos + 1
+ pos += 1
var["var_names"] = var_list
- pos = pos + 1
+ pos += 1
else:
varname = parse_expr(line, pos, r"([,= ]|\s*$)")
var["varname"] = varname
pos = varname.end
if not mterminated.match(line, pos) and line[pos] == '=':
- pos = pos + 1
+ pos += 1
val = parse_expr(line, pos, r"([ ,]|\s*$)")
var["val"] = val
pos = val.end
@@ -508,7 +508,7 @@
del var["varname"]
var_set.append(var)
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
parent_tok.var_set = var_set
parent_tok.end = pos
@@ -519,10 +519,10 @@
while not mterminated.match(line, pos):
if line[pos] == '!':
sub_token = Token(FCC_NEWLINE, pos)
- pos = pos + 1
+ pos += 1
elif line[pos] == '#':
sub_token = Token(FCC_NEWPAGE, pos)
- pos = pos + 1
+ pos += 1
elif line[pos] == '?':
sub_token = Token(FCC_MOV, pos)
offset = parse_expr(line, pos + 1, r"([, ]|\s*$)")
@@ -548,7 +548,7 @@
sub_token.timeout = timeout
pos = timeout.end
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
read_list.append(sub_token)
parent_tok.read_list = read_list
@@ -570,20 +570,20 @@
mterminated = MUMPS_RE_DICT["cmdEnd"]
while not mterminated.match(line, pos):
if line[pos] == '(':
- pos = pos + 1
+ pos += 1
while line[pos] != ')':
vartok = parse_expr(line, pos, r"([,)])")
pos = vartok.end
excl_list.append(vartok)
if line[pos] == ',':
- pos = pos + 1
- pos = pos + 1 # eat the closing parens.
+ pos += 1
+ pos += 1 # eat the closing parens.
else:
vartok = parse_expr(line, pos, r"([ ,]|\s*$)")
pos = vartok.end
new_list.append(vartok)
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
parent_tok.new_list = new_list
parent_tok.excl_list = excl_list
@@ -599,13 +599,13 @@
merge_item["l_item"] = recipient
pos = recipient.end
if not mterminated.match(line, pos) and line[pos] == '=':
- pos = pos + 1
+ pos += 1
copy_item = parse_expr(line, pos, r"([, ]|\s*$)")
merge_item["r_item"] = copy_item
pos = copy_item.end
items.append(merge_item)
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
parent_tok.items = items
parent_tok.end = pos
@@ -617,31 +617,31 @@
lock_item = {}
if line[pos] in ('+', '-'):
lock_item["op"] = line[pos]
- pos = pos + 1
+ pos += 1
if line[pos] == '(':
nref_list = []
- pos = pos + 1
+ pos += 1
while line[pos] != ')':
nref = parse_expr(line, pos, r"([,)])")
pos = nref.end
nref_list.append(nref)
if line[pos] == ',':
- pos = pos + 1
+ pos += 1
lock_item["nrefs"] = nref_list
- pos = pos + 1 # eat the closing parenthesis
+ pos += 1 # eat the closing parenthesis
else:
nref = parse_expr(line, pos, r"([ ,:]|\s*$)")
pos = nref.end
lock_item["nrefs"] = (nref, )
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
timeout = parse_expr(line, pos, r"[ ,]|\s*$")
for nref in lock_item["nrefs"]:
nref.timeout = timeout
pos = timeout.end
lock_list.append(lock_item)
if line[pos] == ',':
- pos = pos + 1
+ pos += 1
parent_tok.lock_list = lock_list
parent_tok.end = pos
@@ -652,20 +652,20 @@
mterminated = MUMPS_RE_DICT["cmdEnd"]
while not mterminated.match(line, pos):
if line[pos] == '(':
- pos = pos + 1
+ pos += 1
while line[pos] != ')':
vartok = parse_expr(line, pos, r"([,)])")
pos = vartok.end
excl_list.append(vartok)
if line[pos] == ',':
- pos = pos + 1
- pos = pos + 1 # eat the closing parens.
+ pos += 1
+ pos += 1 # eat the closing parens.
else:
vartok = parse_expr(line, pos, r"([ ,]|\s*$)")
pos = vartok.end
kill_list.append(vartok)
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
parent_tok.kill_list = kill_list
parent_tok.excl_list = excl_list
@@ -678,16 +678,16 @@
while not mterminated.match(line, pos):
(entry_ref, pos) = parse_entry_ref(line, pos)
if not mterminated.match(line, pos) and line[pos] == '(':
- pos = pos + 1
+ pos += 1
params = []
while line[pos] != ")":
paramtok = parse_expr(line, pos, r"([,)])")
params.append(paramtok)
pos = paramtok.end
if line[pos] == ',':
- pos = pos + 1
+ pos += 1
entry_ref.params = params
- pos = pos + 1
+ pos += 1
if not mterminated.match(line, pos) and line[pos] == '[':
uci = parse_expr(line, pos + 1, r",|[]]")
entry_ref.uci = uci
@@ -696,27 +696,27 @@
uci_sys = parse_expr(line, pos + 1, r"[]]")
entry_ref.uci_sys = uci_sys
pos = uci_sys.end
- pos = pos + 1 # eat the closing ']'
+ pos += 1 # eat the closing ']'
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
if line[pos] == '(':
- pos = pos + 1
+ pos += 1
keyword_list = []
while line[pos] != ')':
keyword = parse_expr(line, pos, r"([:)])")
keyword_list.append(keyword)
pos = keyword.end
if line[pos] == ':':
- pos = pos + 1
- pos = pos + 1
+ pos += 1
+ pos += 1
entry_ref.keyword_list = keyword_list
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
timeout = parse_expr(line, pos, r"[ ,]|\s*$")
entry_ref.timeout = timeout
pos = timeout.end
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
entry_ref_list.append(entry_ref)
parent_tok.entry_ref = entry_ref_list
parent_tok.end = pos
@@ -730,7 +730,7 @@
expr_list.append(exprtok)
pos = exprtok.end
if line[pos] == ",":
- pos = pos + 1
+ pos += 1
parent_tok.condition_list = expr_list
parent_tok.end = pos + 1
@@ -747,12 +747,12 @@
while not mterminated.match(line, pos):
(entry_ref, pos) = parse_entry_ref(line, pos)
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
condtok = parse_expr(line, pos, r"([ ,]|\s$)")
entry_ref.post_condition(condtok)
pos = condtok.end
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
entry_ref_list.append(entry_ref)
parent_tok.entry_ref = entry_ref_list
@@ -771,18 +771,18 @@
loop_vals["initVal"] = parse_expr(line, pos, r"([,: ]|\s$)")
pos = loop_vals["initVal"].end
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
incr_val = parse_expr(line, pos, r"([ :,]|\s$)")
loop_vals["IncrVal"] = incr_val
pos = incr_val.end
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
terminal_val = parse_expr(line, pos, r"([ :,]|\s$)")
loop_vals["TermVal"] = terminal_val
pos = terminal_val.end
loops.append(loop_vals)
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
parent_tok.loop_incr_var = loop_incr_var
parent_tok.for_loops = loops
@@ -795,23 +795,23 @@
while not mterminated.match(line, pos):
(entry_ref, pos) = parse_entry_ref(line, pos)
if not mterminated.match(line, pos) and line[pos] == '(':
- pos = pos + 1
+ pos += 1
params = []
while line[pos] != ")":
paramtok = parse_expr(line, pos, r"([,)])")
params.append(paramtok)
pos = paramtok.end
if line[pos] == ',':
- pos = pos + 1
+ pos += 1
entry_ref.params = params
- pos = pos + 1
+ pos += 1
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
condtok = parse_expr(line, pos, r"([ ,]|\s$)")
entry_ref.post_condition(condtok)
pos = condtok.end
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
entry_ref_list.append(entry_ref)
parent_tok.entry_ref = entry_ref_list
@@ -827,9 +827,9 @@
device["Expr"] = expr
pos = expr.end
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
if line[pos] == '(':
- pos = pos + 1
+ pos += 1
keyword_list = []
while line[pos] != ')':
keyword = parse_expr(line, pos, r"[,:=)]")
@@ -840,9 +840,9 @@
keyword.keyval = kval
pos = kval.end
if line[pos] in (':', ','):
- pos = pos + 1
+ pos += 1
device["keyword_list"] = keyword_list
- pos = pos + 1
+ pos += 1
else:
keyword = parse_expr(line, pos, r"[ =:,]|\s*$")
device["keyword_list"] = [keyword, ]
@@ -852,18 +852,18 @@
r"[ ,:)]|\s*$")
pos = keyword.keyval.end
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
timeout = parse_expr(line, pos, r"[ ,:]|\s*$")
device["Expr"].timeout = timeout
pos = timeout.end
if not mterminated.match(line, pos) and line[pos] == ':':
- pos = pos + 1
+ pos += 1
mnemonic_space = parse_expr(line, pos, r"[ ,]|\s*$")
device["Expr"].mnemonic_space = mnemonic_space
pos = mnemonic_space.end
if not mterminated.match(line, pos) and line[pos] == ',':
- pos = pos + 1
+ pos += 1
device_list.append(device)
parent_tok.device_list = device_list
parent_tok.end = pos
@@ -880,7 +880,7 @@
exprtok.post_condition(condtok)
pos = condtok.end
if line[pos] == ",":
- pos = pos + 1
+ pos += 1
expr_list.append(exprtok)
parent_tok.Xecute = expr_list