misc: Views and Iterators instead of Lists in python3
* dict methods dict.keys(), dict.items() and dict.values() return "views" instead of lists * The dict.iterkeys(), dict.iteritems() and dict.itervalues() methods are no longer supported. * map() and filter() return iterators. * range() now behaves like xrange() used to behave, except it works with values of arbitrary size. The latter no longer exists. * zip() now returns an iterator. Change-Id: Id480018239db88d7f5d60588c93719056de4a0c0 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26248 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -265,7 +265,7 @@ def blobToCpp(data, symbol, cpp_code, hpp_code=None, namespace=None):
|
||||
cpp_code(symbol_declaration + ' = {')
|
||||
cpp_code.indent()
|
||||
step = 16
|
||||
for i in xrange(0, len(data), step):
|
||||
for i in six.moves.range(0, len(data), step):
|
||||
x = array.array('B', data[i:i+step])
|
||||
cpp_code(''.join('%d,' % d for d in x))
|
||||
cpp_code.dedent()
|
||||
@@ -661,7 +661,7 @@ def makeTheISA(source, target, env):
|
||||
|
||||
code.write(str(target[0]))
|
||||
|
||||
env.Command('config/the_isa.hh', map(Value, all_isa_list),
|
||||
env.Command('config/the_isa.hh', list(map(Value, all_isa_list)),
|
||||
MakeAction(makeTheISA, Transform("CFG ISA", 0)))
|
||||
|
||||
def makeTheGPUISA(source, target, env):
|
||||
@@ -706,7 +706,7 @@ def makeTheGPUISA(source, target, env):
|
||||
|
||||
code.write(str(target[0]))
|
||||
|
||||
env.Command('config/the_gpu_isa.hh', map(Value, all_gpu_isa_list),
|
||||
env.Command('config/the_gpu_isa.hh', list(map(Value, all_gpu_isa_list)),
|
||||
MakeAction(makeTheGPUISA, Transform("CFG ISA", 0)))
|
||||
|
||||
########################################################################
|
||||
@@ -797,7 +797,7 @@ sys.meta_path.remove(importer)
|
||||
sim_objects = m5.SimObject.allClasses
|
||||
all_enums = m5.params.allEnums
|
||||
|
||||
for name,obj in sorted(sim_objects.iteritems()):
|
||||
for name,obj in sorted(sim_objects.items()):
|
||||
for param in obj._params.local.values():
|
||||
# load the ptype attribute now because it depends on the
|
||||
# current version of SimObject.allClasses, but when scons
|
||||
@@ -920,7 +920,7 @@ def createSimObjectPyBindWrapper(target, source, env):
|
||||
|
||||
# Generate all of the SimObject param C++ struct header files
|
||||
params_hh_files = []
|
||||
for name,simobj in sorted(sim_objects.iteritems()):
|
||||
for name,simobj in sorted(sim_objects.items()):
|
||||
py_source = PySource.modules[simobj.__module__]
|
||||
extra_deps = [ py_source.tnode ]
|
||||
|
||||
@@ -932,7 +932,7 @@ for name,simobj in sorted(sim_objects.iteritems()):
|
||||
|
||||
# C++ parameter description files
|
||||
if GetOption('with_cxx_config'):
|
||||
for name,simobj in sorted(sim_objects.iteritems()):
|
||||
for name,simobj in sorted(sim_objects.items()):
|
||||
py_source = PySource.modules[simobj.__module__]
|
||||
extra_deps = [ py_source.tnode ]
|
||||
|
||||
@@ -957,14 +957,14 @@ if GetOption('with_cxx_config'):
|
||||
|
||||
code = code_formatter()
|
||||
|
||||
for name,simobj in sorted(sim_objects.iteritems()):
|
||||
for name,simobj in sorted(sim_objects.items()):
|
||||
if not hasattr(simobj, 'abstract') or not simobj.abstract:
|
||||
code('#include "cxx_config/${name}.hh"')
|
||||
code()
|
||||
code('void cxxConfigInit()')
|
||||
code('{')
|
||||
code.indent()
|
||||
for name,simobj in sorted(sim_objects.iteritems()):
|
||||
for name,simobj in sorted(sim_objects.items()):
|
||||
not_abstract = not hasattr(simobj, 'abstract') or \
|
||||
not simobj.abstract
|
||||
if not_abstract and 'type' in simobj.__dict__:
|
||||
@@ -979,14 +979,14 @@ if GetOption('with_cxx_config'):
|
||||
env.Command(cxx_config_init_cc_file, Value(name),
|
||||
MakeAction(createCxxConfigInitCC, Transform("CXXCINIT")))
|
||||
cxx_param_hh_files = ["cxx_config/%s.hh" % simobj
|
||||
for name,simobj in sorted(sim_objects.iteritems())
|
||||
for name,simobj in sorted(sim_objects.items())
|
||||
if not hasattr(simobj, 'abstract') or not simobj.abstract]
|
||||
Depends(cxx_config_init_cc_file, cxx_param_hh_files +
|
||||
[File('sim/cxx_config.hh')])
|
||||
Source(cxx_config_init_cc_file)
|
||||
|
||||
# Generate all enum header files
|
||||
for name,enum in sorted(all_enums.iteritems()):
|
||||
for name,enum in sorted(all_enums.items()):
|
||||
py_source = PySource.modules[enum.__module__]
|
||||
extra_deps = [ py_source.tnode ]
|
||||
|
||||
@@ -1003,7 +1003,7 @@ for name,enum in sorted(all_enums.iteritems()):
|
||||
|
||||
# Generate SimObject Python bindings wrapper files
|
||||
if env['USE_PYTHON']:
|
||||
for name,simobj in sorted(sim_objects.iteritems()):
|
||||
for name,simobj in sorted(sim_objects.items()):
|
||||
py_source = PySource.modules[simobj.__module__]
|
||||
extra_deps = [ py_source.tnode ]
|
||||
cc_file = File('python/_m5/param_%s.cc' % name)
|
||||
@@ -1055,7 +1055,7 @@ namespace Debug {
|
||||
|
||||
''')
|
||||
|
||||
for name, flag in sorted(source[0].read().iteritems()):
|
||||
for name, flag in sorted(source[0].read().items()):
|
||||
n, compound, desc = flag
|
||||
assert n == name
|
||||
|
||||
@@ -1117,7 +1117,7 @@ namespace Debug {
|
||||
|
||||
code.write(str(target[0]))
|
||||
|
||||
for name,flag in sorted(debug_flags.iteritems()):
|
||||
for name,flag in sorted(debug_flags.items()):
|
||||
n, compound, desc = flag
|
||||
assert n == name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user