diff options
Diffstat (limited to 'bench/env.__setitem__.py')
-rw-r--r-- | bench/env.__setitem__.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/bench/env.__setitem__.py b/bench/env.__setitem__.py index d20785a..61d8c1e 100644 --- a/bench/env.__setitem__.py +++ b/bench/env.__setitem__.py @@ -6,7 +6,6 @@ import os.path import re -import string import sys import timeit @@ -174,7 +173,7 @@ class env_global_regex_is_valid(Environment): class env_special_set_has_key(Environment): """_special_set.get(): use _special_set.has_key() instead""" def __setitem__(self, key, value): - if self._special_set.has_key(key): + if key in self._special_set: self._special_set[key](self, key, value) else: if not SCons.Environment.is_valid_construction_var(key): @@ -232,7 +231,7 @@ class env_not_has_key(Environment): if special: special(self, key, value) else: - if not self._dict.has_key(key) \ + if key not in self._dict \ and not SCons.Environment.is_valid_construction_var(key): raise SCons.Errors.UserError, "Illegal construction variable `%s'" % key self._dict[key] = value @@ -243,7 +242,7 @@ class env_Best_attribute(Environment): if key in self._special_set_keys: self._special_set[key](self, key, value) else: - if not self._dict.has_key(key) \ + if key not in self._dict \ and not global_valid_var.match(key): raise SCons.Errors.UserError, "Illegal construction variable `%s'" % key self._dict[key] = value @@ -251,10 +250,10 @@ class env_Best_attribute(Environment): class env_Best_has_key(Environment): """Best __setitem__(), with has_key""" def __setitem__(self, key, value): - if self._special_set.has_key(key): + if key in self._special_set: self._special_set[key](self, key, value) else: - if not self._dict.has_key(key) \ + if key not in self._dict \ and not global_valid_var.match(key): raise SCons.Errors.UserError, "Illegal construction variable `%s'" % key self._dict[key] = value @@ -265,7 +264,7 @@ class env_Best_list(Environment): if key in ['BUILDERS', 'SCANNERS', 'TARGET', 'TARGETS', 'SOURCE', 'SOURCES']: self._special_set[key](self, key, value) else: - if not self._dict.has_key(key) \ + if key not in self._dict \ and not global_valid_var.match(key): raise SCons.Errors.UserError, "Illegal construction variable `%s'" % key self._dict[key] = value @@ -278,7 +277,7 @@ else: class env_isalnum(Environment): """Greg's Folly: isalnum instead of probe""" def __setitem__(self, key, value): - if self._special_set.has_key(key): + if key in self._special_set: self._special_set[key](self, key, value) else: if not key.isalnum() and not global_valid_var.match(key): @@ -324,7 +323,7 @@ common_import_variables = ['do_it'] + class_names common_imports = """ from __main__ import %s -""" % string.join(common_import_variables, ', ') +""" % ', '.join(common_import_variables) # The test data (lists of variable names) that we'll use for the runs. @@ -340,10 +339,10 @@ def run_it(title, init): s['num'] = iterations s['title'] = title s['init'] = init - apply(times,(),s) + times(**s) print 'Environment __setitem__ benchmark using', -print 'Python', string.split(sys.version)[0], +print 'Python', sys.version.split()[0], print 'on', sys.platform, os.name run_it('Results for re-adding an existing variable name 100 times:', |