On Sep 15, 2011, at 8:45 AM, Ross Peoples wrote:
> The other big performance hit is that 2-3 places in web2py we do this:
>
> import contrib.simplejson as simplejson
>
> That really needs to change to something like this (with corresponding
> changes to the code)
>
> try:
> import json # try stdlib (py2.6)
> except ImportError:
> try:
> import simplejson as json # try external module
> except:
> import gluon.contrib.simplejson as json # fall back on pure-Python
> module
>
> The problem is that we need to be using the optimized C libraries when we can
> (that's why XML is faster, I think). But the copy in contrib is pure Python.
> It works, but it's slow.
>
>
>
> I had a feeling this might have something to do with it. I wonder if
> preferring the pure Python libraries is adding to Problem #1.
I can't think how, but it'd be interesting to find out.
A temporary alternative would be to write this:
try:
import json as simplejson # try stdlib (py2.6)
except ImportError:
try:
import simplejson # try external module
except:
import gluon.contrib.simplejson as simplejson # fall back on
pure-Python module
...so as not to disturb the existing naming. It'd need to be done in
gluon.serializers and utils (I think--wherever Service is defined).