Skip to content

Instantly share code, notes, and snippets.

@kapilt
Created April 2, 2010 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kapilt/353480 to your computer and use it in GitHub Desktop.
Save kapilt/353480 to your computer and use it in GitHub Desktop.
from msgpack import packs, unpacks
from simplejson import dumps, loads
d = {'x':range(100), 'y':{'abc':'def'}, 'zero':None}
d['x'].append('a')
import time
def time_msgpack():
stime = time.time()
for i in range(1000):
assert unpacks(packs(d)) == d
print time.time()-stime
def time_json():
stime = time.time()
for i in range(1000):
assert loads(dumps(d)) == d
print time.time()-stime
if __name__ == '__main__':
time_msgpack()
time_json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment