[Python-Dev] Dropping bytes "support" in json
Antoine Pitrou
solipsis at pitrou.net
Thu Apr 9 01:31:31 CEST 2009
Martin v. Löwis <martin <at> v.loewis.de> writes:
>
> What does Bob Ippolito think about this change? IIUC, he considers
> simplejson's speed one of its primary advantages, and also attributes it
> to the fact that he can parse directly out of byte strings, and marshal
> into them (which is important, as you typically receive them over the
> wire).
The only thing I know is that the new version (the one I've tried to merge) is
massively faster than the old one - several times faster - and within 20-30% of
the speed of the 2.x version (*). Besides, Bob doesn't really seem to care about
porting to py3k (he hasn't said anything about it until now, other than that he
didn't feel competent to do it). But I'm happy with someone proposing an
alternate patch if they want to. As for me, I just wanted to fill the gap and
I'm not interested in doing lot of work on this issue.
(*)
timeit -s "import json; l=['abc']*100" "json.dumps(l)"
-> trunk: 33.4 usec per loop
-> py3k + patch: 37.1 usec per loop
-> vanilla py3k: 314 usec per loop
timeit -s "import json; s=json.dumps(['abc']*100)" "json.loads(s)"
-> trunk: 44.8 usec per loop
-> py3k + patch: 35.4 usec per loop
-> vanilla py3k: 1.48 msec per loop (!)
Regards
Antoine.
More information about the Python-Dev
mailing list