On Sun, 17 Apr 2011 09:21:32 +0200
Stefan Behnel
Antoine Pitrou, 16.04.2011 19:27:
On Sat, 16 Apr 2011 16:47:49 +0000 (UTC) Vinay Sajip wrote:
Bob made a comment in passing that simplejson (Python) is about as fast as stdlib json (C extension), on 2.x.
I think Bob tested with an outdated version of the stdlib json module (2.6 or 2.7, perhaps). In my latest measurements, the 3.2 json C module is as fast as the C simplejson module, the only difference being in parsing of numbers, which is addressed in http://bugs.python.org/issue11856
Ok, but then, what's the purpose of having the old Python implementation in the stdlib? The other Python implementations certainly won't be happy with something that is way slower (algorithmically!) than the current version of the non-stdlib implementation.
Again, I don't think it's "way slower" since the code should be almost identical (simplejson hasn't changed much in the last year). That's assuming you measure performance on 3.2 or 3.3, not something older. Besides, the primary selling point of the stdlib implementation is that... it's the stdlib implementation. You have a json serializer/deserializer by default without having to install any third-party package. For most people that's probably sufficient; people with specific needs *may* benefit from installing simplejson. Also, the pure Python paths are still used if you customize some parameters (I don't remember which ones exactly, you could take a look at e.g. Lib/json/encoder.py if you are interested). Regards Antoine.