[pypy-commit] pypy default: use memcpy one more time in array.__delslice__ for extra speediness

Justin Peel noreply at buildbot.pypy.org
Mon Oct 22 07:35:27 CEST 2012


Author: Justin Peel <peelpy at gmail.com>
Branch: 
Changeset: r58351:4ffa41843837
Date: 2012-10-21 23:35 -0600
http://bitbucket.org/pypy/pypy/changeset/4ffa41843837/

Log:	use memcpy one more time in array.__delslice__ for extra speediness

diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -491,10 +491,11 @@
                 rffi.cast(rffi.VOIDP, oldbuffer),
                 i * mytype.bytes
             )
-        m = i
-        for k in range(j, self.len):
-            self.buffer[m] = oldbuffer[k]
-            m += 1
+        if j < self.len:
+            rffi.c_memcpy(
+                rffi.cast(rffi.VOIDP, rffi.ptradd(self.buffer, i)),
+                rffi.cast(rffi.VOIDP, rffi.ptradd(oldbuffer, j)),
+                (self.len - j) * mytype.bytes)
         self.len -= j - i
         self.allocated = self.len
         if oldbuffer:


More information about the pypy-commit mailing list