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:
Giacomo Travaglini
2020-03-02 14:30:25 +00:00
parent e9fea79dfc
commit 10b4842407
12 changed files with 69 additions and 67 deletions

View File

@@ -686,7 +686,7 @@ class MetaSimObject(type):
# the object itself, not including inherited params (which
# will also be inherited from the base class's param struct
# here). Sort the params based on their key
params = map(lambda k_v: k_v[1], sorted(cls._params.local.items()))
params = list(map(lambda k_v: k_v[1], sorted(cls._params.local.items())))
ports = cls._ports.local
code('''#include "pybind11/pybind11.h"
@@ -783,7 +783,7 @@ module_init(py::module &m_internal)
# the object itself, not including inherited params (which
# will also be inherited from the base class's param struct
# here). Sort the params based on their key
params = map(lambda k_v: k_v[1], sorted(cls._params.local.items()))
params = list(map(lambda k_v: k_v[1], sorted(cls._params.local.items())))
ports = cls._ports.local
try:
ptypes = [p.ptype for p in params]