Author: Wim Lavrijsen <wlavrij...@lbl.gov> Branch: cppyy-dev Changeset: r97989:466fe5506d3d Date: 2019-11-07 11:37 -0800 http://bitbucket.org/pypy/pypy/changeset/466fe5506d3d/
Log: simplify iteration over std::list/map diff --git a/pypy/module/_cppyy/pythonify.py b/pypy/module/_cppyy/pythonify.py --- a/pypy/module/_cppyy/pythonify.py +++ b/pypy/module/_cppyy/pythonify.py @@ -439,14 +439,17 @@ # also the fallback on the indexed __getitem__, but that is slower) add_checked_item = False if name.find('std::vector', 0, 11) != 0: - if ('begin' in pyclass.__dict__ and 'end' in pyclass.__dict__): + if 'begin' in pyclass.__dict__ and 'end' in pyclass.__dict__: if _cppyy._scope_byname(name+'::iterator') or \ _cppyy._scope_byname(name+'::const_iterator'): def __iter__(self): i = self.begin() - while i != self.end(): + end = self.size() + count = 0 + while count != end: yield i.__deref__() i.__preinc__() + count += 1 i.__destruct__() raise StopIteration pyclass.__iter__ = __iter__ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit