[pypy-issue] [issue1423] performance characteristics of pickle StringBuilder wrapper

Brian Kearns tracker at bugs.pypy.org
Sat Mar 16 20:00:13 CET 2013

New submission from Brian Kearns <bdkearns at gmail.com>:

Without changeset 519e4fca15cb, shown below, performance on the following script 
is 20% worse. Shouldn't they be able to be optimized equally well? Is this a 
missed optimization?

diff --git a/lib-python/2/pickle.py b/lib-python/2/pickle.py
--- a/lib-python/2/pickle.py
+++ b/lib-python/2/pickle.py
@@ -1418,9 +1418,7 @@
     def __init__(self):
         self.builder = StringBuilder()
-    def write(self, data):
-        self.builder.append(data)
+        self.write = self.builder.append
     def getvalue(self):
         return self.builder.build()


import pickle

class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

def test():
    n_loops = 200000
    N = 2
    data = [Point(x, y) for x in xrange(N) for y in xrange(N)]
    for _ in xrange(n_loops):
        len(pickle.dumps(data, pickle.HIGHEST_PROTOCOL))


messages: 5454
nosy: bdk, pypy-issue
priority: performance bug
status: unread
title: performance characteristics of pickle StringBuilder wrapper

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

More information about the pypy-issue mailing list