[Python-checkins] cpython: Issue #12805: Make bytes.join and bytearray.join faster when the separator is
antoine.pitrou
python-checkins at python.org
Sat Oct 20 23:14:55 CEST 2012
http://hg.python.org/cpython/rev/bfa715f98c0f
changeset: 79859:bfa715f98c0f
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Oct 20 23:08:34 2012 +0200
summary:
Issue #12805: Make bytes.join and bytearray.join faster when the separator is empty.
Patch by Serhiy Storchaka.
files:
Misc/NEWS | 3 +++
Objects/stringlib/join.h | 10 ++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #12805: Make bytes.join and bytearray.join faster when the separator
+ is empty. Patch by Serhiy Storchaka.
+
- Issue #6074: Ensure cached bytecode files can always be updated by the
user that created them, even when the source file is read-only.
diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h
--- a/Objects/stringlib/join.h
+++ b/Objects/stringlib/join.h
@@ -94,6 +94,16 @@
/* Catenate everything. */
p = STRINGLIB_STR(res);
+ if (!seplen) {
+ /* fast path */
+ for (i = 0; i < nbufs; i++) {
+ Py_ssize_t n = buffers[i].len;
+ char *q = buffers[i].buf;
+ Py_MEMCPY(p, q, n);
+ p += n;
+ }
+ goto done;
+ }
for (i = 0; i < nbufs; i++) {
Py_ssize_t n;
char *q;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list