SimpleJson is slow .... is there any C Compiled version ?

sanket sanket.s.patel at gmail.com
Fri Jul 25 23:04:19 EDT 2008


On Jul 25, 5:52 pm, Matt Nordhoff <mnordh... at mattnordhoff.com> wrote:
> sanket wrote:
> > Hello All,
>
> > I have created an API which fetches some data from the database.
> > I am using simplejson to encode it and return it back.
>
> > Now the problem is that, this API is being called for millions of
> > times in a sequence.
> > I ran a profiler and saw that most of the time is consumed in encoding
> > my database results in to json.
> > So I was just wondering is there any C compiled version of simplejson
> > is available?
> > or any help regarding this issue would be appreciated.
>
> > Thank you,
> > Sanket
>
> simplejson is not the only JSON library out there. For example, there's
> python-cjson, which is written entirely in C:
>
> <http://pypi.python.org/pypi/python-cjson>
>
> There's also an enhanced version of it:
>
> <http://python.cx.hu/python-cjson/>
>
> I think simplejson has some small, optional C bits that will improve
> performance if you compile them.
>
> Also, be aware that I think simplejson is being integrated into the
> stdlib in Python 2.6.
>
> Also, simplejson and python-cjson might not be entirely compatible:
> there's one character that one escapes and the other doesn't, or something.
> --

Thanks Matt.
I used cjson and it appears to be 5-6 times faster.

Thank you,
Sanket



More information about the Python-list mailing list