Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2.7 on App Engine, simplejson vs native json, who's faster?

I've had the understanding that simplejson is much faster than the native json in Python, such as this thread: What are the differences between json and simplejson Python modules?

However, I was just thrown for a loop when I read in App Engines documentation that with Python 2.7

Uses the native JSON library, which is much faster than simplejson.

http://code.google.com/appengine/docs/python/python27/newin27.html

So now I'm confused. Everywhere else it seems to say simplejson is better, but now App Engine with Python 2.7 says the native is faster. What gives?

like image 533
adam Avatar asked Nov 19 '11 04:11

adam


2 Answers

Before the release of the Python 2.7 runtime, nearly every module included with App Engine, and literally every module you could include yourself were pure python. With the 2.7 release, the json module includes speedups written in C, making it much faster than any simplejson you can run on App Engine.

The benefits to using simplejson on 2.7 you get normally (mainly having a version that's newer than it was when the latest release of Python 2.7 was made) don't apply, since you can't compile the speedups in the latest version and deploy them to App Engine.

like image 128
Wooble Avatar answered Nov 15 '22 21:11

Wooble


I found myself forced to do a straight import json when I migrated to python 2.7. In my app I had to change from simplejson to this. You might find it generally recommendable to keep maximum compatibility with your "main component" and I consider python 2.7 one of my project's main uses / components where the others are Jinja2, WTForms and the i18n translations.

like image 37
Niklas Rosencrantz Avatar answered Nov 15 '22 20:11

Niklas Rosencrantz