On 12/06/12 06:14, Alex Ogier wrote: > This seemed strange to me because the standard library json shipping > with python 2.7.3 is in fact simplejson 2.0.9, so I did some digging. > It turns out that if the C extensions have been compiled and you pass > a str instance to loads(), then you get that behavior in both > versions. This isn't documented anywhere, but here's the offending > pieces: > > http://hg.python.org/releasing/2.7.3/file/7bb96963d067/Modules/_json.c#l419 > https://github.com/simplejson/simplejson/blob/master/simplejson/_speedups.c#L527 > > If the C extensions aren't enabled, or you pass a unicode string to > loads(), then you get the "proper" behavior as documented. I'm not > sure how you are triggering this optimized, iffy behavior in > django.utils.simplejson though, without also triggering it in the > standard library. Did you ever install simplejson with 'pip install > simplejson' such that Django picked it up? Can you try running 'from > django.utils import simplejson; print simplejson.__version__'?
Thanks for digging into that. (BTW, in reply to Vinay, yes I meant "from simplejson to json", not the other way around). I've found the same difference of behaviour on both a production machine where I'm running my app (CentOS machine, using a virtualenv, Python 2.7.3), and locally on my dev machine which is currently running Debian, using the Debian Python 2.7.2 packages. In both cases, json is always returning unicode objects, which implies I don't have the C extensions for the json module according to your analysis. I don't know enough about how this is supposed to work to understand why. It also implies I probably not the only one affected by this, if it's happened on two quite different machines. Looking at this discussion: http://stackoverflow.com/questions/712791/json-and-simplejson-module-differences-in-python it seems that lots of people don't have the C extension for json (reporting json 10x slower than simplejson). Luke -- OSBORN'S LAW Variables won't, constants aren't. Luke Plant || http://lukeplant.me.uk/ -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.