]> jfr.im git - irc/quakenet/qwebirc.git/blob - qwebirc/util/qjson.py
Merge branch 'master' into quakenet
[irc/quakenet/qwebirc.git] / qwebirc / util / qjson.py
1 slow = True
2 try:
3 # first try the system module
4 import simplejson as json
5 try:
6 # try to see if the C module is available
7 json._speedups
8 except AttributeError:
9 pass
10 else:
11 slow = False
12 except ImportError:
13 # try python 2.6's json library as
14 # it is 2x as fast as simplejson with no C
15 try:
16 import json
17 json.dumps # we don't want the silly third party version
18 except (ImportError, AttributeError):
19 # fallback to the embedded
20 import esimplejson as json
21
22 __SEPS = (',', ':')
23 dumps = lambda x: json.dumps(x, encoding="utf8", ensure_ascii=True, check_circular=False, indent=None, separators=__SEPS)
24 loads = lambda x: json.loads(x, encoding="utf8")