[pypy-commit] pypy py3.5: Improve performance of bytearray.extend(<bytes>)

rlamy pypy.commits at gmail.com
Sun Jul 16 10:22:41 EDT 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r91907:75b45f45de1b
Date: 2017-07-16 16:22 +0200
http://bitbucket.org/pypy/pypy/changeset/75b45f45de1b/

Log:	Improve performance of bytearray.extend(<bytes>)

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -748,8 +748,11 @@
     if space.isinstance_w(w_source, space.w_unicode):
         raise oefmt(space.w_TypeError,
                     "cannot convert a (unicode) str object to bytes")
+    return _from_byte_sequence(space, w_source)
 
-    # sequence of bytes
+
+def _from_byte_sequence(space, w_source):
+    # Split off in a separate function for the JIT's benefit
     w_result = space.appexec([w_source], """(seq):
         result = bytearray()
         for i in seq:


More information about the pypy-commit mailing list