Add lightweight iterators for tuple, list and sequence

Slightly reduces binary size (range for loops over tuple/list benefit
a lot). The iterators are compatible with std algorithms.
This commit is contained in:
Dean Moldovan
2017-02-09 23:05:33 +01:00
committed by Wenzel Jakob
parent 1fac1b9f5f
commit 5637af7b67
3 changed files with 182 additions and 18 deletions

View File

@@ -117,3 +117,9 @@ def test_python_iterator_in_cpp():
l = [1, None, 0, None]
assert m.count_none(l) == 2
assert m.find_none(l) is True
assert m.count_nonzeros({"a": 0, "b": 1, "c": 2}) == 2
r = range(5)
assert all(m.tuple_iterator(tuple(r)))
assert all(m.list_iterator(list(r)))
assert all(m.sequence_iterator(r))