[Buildbot-commits] [Buildbot] #1857: buildbot.util should prefer simplejson over built-in json

Buildbot nobody at buildbot.net
Sun Mar 6 01:57:53 UTC 2011


#1857: buildbot.util should prefer simplejson over built-in json
------------------------+-----------------------
Reporter:  catlee       |      Owner:
    Type:  enhancement  |     Status:  new
Priority:  minor        |  Milestone:  undecided
 Version:  0.8.3p1      |   Keywords:
------------------------+-----------------------
 Python 2.6's json is significantly slower than simplejson.

 {{{
 import json
 import simplejson
 import time

 def task(module, data):
     encoded = module.dumps(data)
     orig = module.loads(encoded)
     assert data == orig

 n = 1000

 data = {}
 for i in range(100):
     data[str(i)] = "hello" * i

 for module in json, simplejson:
     s = time.time()
     for i in range(n):
         task(module, data)
     e = time.time()
     print module.__name__, e-s
 }}}

 outputs
 {{{
 json 1.52023100853
 simplejson 0.200721979141
 }}}

 on my system with python 2.6.6.

 Python 2.7 is much improved:
 {{{
 json 0.206233024597
 simplejson 0.189265012741
 }}}

 Buildbot should prefer simplejson for python <= 2.6.

-- 
Ticket URL: <http://trac.buildbot.net/ticket/1857>
Buildbot <http://buildbot.net/>
Buildbot: build/test automation


More information about the Commits mailing list