From 4179c6703737c6927ac292367f06522820daaf9e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 9 Apr 2011 23:45:50 +0200 Subject: [PATCH] dict acceleration Version:1.1.65 --- src/command_line.py | 4 ++-- src/create_man.py | 6 +++--- src/makefile.py | 4 ++-- src/modules.py | 2 +- src/parsed_text.py | 16 ++++++++-------- src/preprocessed_text.py | 5 ++--- src/version.py | 2 +- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/command_line.py b/src/command_line.py index 05ece4a..5c79137 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -102,7 +102,7 @@ Options: def opts(self): if self._opts is None: optlist = ["",[]] - for o in options.keys(): + for o in options: b = [o]+options[o] if b[3] == 1: b[0] = b[0]+":" @@ -132,7 +132,7 @@ def do_$LONG(self): return self._do_$LONG do_$LONG = property(fget=do_$LONG) """ - for short in options.keys(): + for short in options: long = options[short][0] exec t.replace("$LONG",long).replace("$SHORT",short) diff --git a/src/create_man.py b/src/create_man.py index d56d1bf..4e461c9 100644 --- a/src/create_man.py +++ b/src/create_man.py @@ -97,13 +97,13 @@ def do_print(var): def run(): import parsed_text import os,sys - l = variables.keys() if os.fork() == 0: - for v in l: - do_print(variables[v]) + for v in variables.values(): + do_print(v) sys.exit(0) if os.fork() == 0: + l = variables.keys() file = open("irpf90_entities","w") l.sort() for v in l: diff --git a/src/makefile.py b/src/makefile.py index a89865d..02d1631 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -63,8 +63,8 @@ def run(): from modules import modules if os.fork() == 0: mod = [] - for m in modules.keys(): - mod.append(modules[m]) + for m in modules.values(): + mod.append(m) file = open('irpf90.make','w') diff --git a/src/modules.py b/src/modules.py index 1231e44..ec060a2 100644 --- a/src/modules.py +++ b/src/modules.py @@ -63,6 +63,6 @@ def write_module(m): ###################################################################### if __name__ == '__main__': - write_module(modules['electrons.irp.f']) + write_module(modules['psi.irp.f']) diff --git a/src/parsed_text.py b/src/parsed_text.py index 2a03c00..c8a0380 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -166,13 +166,13 @@ def get_parsed_text(): l = line.lower.split()[1:] l = filter(lambda x: x not in varlist, l) for v in l: - if v not in variables.keys(): + if v not in variables: error.fail(line,"Variable %s is unknown"%(v)) append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) ) elif type(line) == NoDep: l = line.lower.split()[1:] for v in l: - if v not in variables.keys(): + if v not in variables: error.fail(line,"Variable %s is unknown"%(v)) l = map(lambda x: "-%s"%(x), l) append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) ) @@ -447,25 +447,25 @@ def build_needs(): funcs = find_funcs_in_line(line) for f in funcs: var.needs += subroutines[f].needs - for v in variables.keys(): + for v in variables: main = variables[v].same_as if main != v: variables[v].needs = variables[main].needs variables[v].to_provide = variables[main].to_provide # Needed_by - for v in variables.keys(): + for v in variables: variables[v].needed_by = [] - for v in variables.keys(): + for v in variables: main = variables[v].same_as if main != v: variables[v].needed_by = variables[main].needed_by - for v in variables.keys(): + for v in variables: var = variables[v] if var.is_main: for x in var.needs: variables[x].needed_by.append(var.same_as) - for v in variables.keys(): + for v in variables: var = variables[v] var.needed_by = make_single(var.needed_by) @@ -507,7 +507,7 @@ check_opt() ###################################################################### if __name__ == '__main__': for i in range(len(parsed_text)): - if parsed_text[i][0] == 'mo.irp.f': + if parsed_text[i][0] == 'psi.irp.f': print '!-------- %s -----------'%(parsed_text[i][0]) for line in parsed_text[i][1]: print line[1] diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 9d3775f..1dff0cb 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -85,7 +85,6 @@ simple_dict = { "function": Function , "recursive": Function , } -simple_dict_keys = simple_dict.keys() def get_type (i, filename, line, is_doc): '''Find the type of a text line''' @@ -126,7 +125,7 @@ def get_type (i, filename, line, is_doc): if is_doc: return [ Doc (i,line,filename) ], is_doc - if firstword in simple_dict_keys: + if firstword in simple_dict: return [ simple_dict[firstword](i,line,filename) ], is_doc if firstword in [ "select", "selectcase" ]: @@ -621,7 +620,7 @@ def irp_simple_statements(text): result = [] for line in text: buffer = [ line ] - for t in d.keys(): + for t in d: if type(line) == t: buffer = d[t](line) break diff --git a/src/version.py b/src/version.py index 6da2d73..f51103f 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.1.64" +version = "1.1.65"