[pypy-issue] [issue866] [PATCH] join is slow about 2x slower than Python

Justin Peel tracker at bugs.pypy.org
Sat Sep 10 00:08:29 CEST 2011

Justin Peel <peelpy at gmail.com> added the comment:

I had another idea. Why not just make a fast path for when all the objects being 
joined are strings? I've attached a patch that does just that.

Benchmark results (code in initial post):

          CPython 2.7.1: 0.22 seconds

Pypy nightly from Sep 3: 0.45 seconds

    Pypy with fast path: 0.21 seconds

It will make things a little bit slower for string-derivative objects or when a 
join is called on a string and there are unicode objects in the list being 
joined. However, I think that the most common case by far is joining a bunch of 
basic strings. What does everyone think of this patch?

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list