[pypy-commit] pypy py3.5: impl and test rmul for deque
plan_rich
pypy.commits at gmail.com
Mon Oct 17 08:31:20 EDT 2016
Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5
Changeset: r87838:865adef88c8a
Date: 2016-10-17 14:30 +0200
http://bitbucket.org/pypy/pypy/changeset/865adef88c8a/
Log: impl and test rmul for deque
diff --git a/pypy/module/_collections/interp_deque.py b/pypy/module/_collections/interp_deque.py
--- a/pypy/module/_collections/interp_deque.py
+++ b/pypy/module/_collections/interp_deque.py
@@ -195,6 +195,9 @@
return space.wrap(copied)
+ def rmul(self, w_int):
+ return self.mul(w_int)
+
def imul(self, w_int):
space = self.space
copy = W_Deque(space)
@@ -578,6 +581,7 @@
__reduce__ = interp2app(W_Deque.reduce),
__mul__ = interp2app(W_Deque.mul),
__imul__ = interp2app(W_Deque.imul),
+ __rmul__ = interp2app(W_Deque.rmul),
maxlen = GetSetProperty(W_Deque.get_maxlen),
)
diff --git a/pypy/module/_collections/test/test_deque.py b/pypy/module/_collections/test/test_deque.py
--- a/pypy/module/_collections/test/test_deque.py
+++ b/pypy/module/_collections/test/test_deque.py
@@ -380,3 +380,9 @@
assert 0, "must raise!"
except RuntimeError:
pass
+
+ def test_deque_rmul(self):
+ from _collections import deque
+ d = deque([1,2])
+ assert 2 * d == deque([1,2,1,2])
+ assert -5 * d == deque()
More information about the pypy-commit
mailing list