[pypy-commit] pypy py3.5: Fix deque mul and implement imul (reubano & plan_rich)

reubano pypy.commits at gmail.com
Sun Oct 9 06:14:51 EDT 2016


Author: Reuben Cummings <reubano at gmail.com>
Branch: py3.5
Changeset: r87660:a9547a8c7444
Date: 2016-10-09 13:14 +0300
http://bitbucket.org/pypy/pypy/changeset/a9547a8c7444/

Log:	Fix deque mul and implement imul (reubano & plan_rich)

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
@@ -185,17 +185,26 @@
         return self.space.wrap(self)
 
     def mul(self, w_int):
-        copied = self.copy()
-        num = self.space.int_w(w_int)
+        space = self.space
+        copied = W_Deque(space)
+        num = space.int_w(w_int)
 
         for _ in range(num):
-            copied.extend(copied)
+            copied.extend(self)
 
-        return self.space.wrap(copied)
+        return space.wrap(copied)
 
 
-    def imul(self, w_iterable):
-        pass
+    def imul(self, w_int):
+        space = self.space
+        copied = self.copy()
+        num = space.int_w(w_int)
+
+        for _ in range(num - 1):
+            self.extend(copied)
+
+        return space.wrap(self)
+
 
     def copy(self):
         """ A shallow copy """


More information about the pypy-commit mailing list