summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIhar Hrachyshka <ihrachys@redhat.com>2014-04-29 12:03:30 +0200
committerIhar Hrachyshka <ihrachys@redhat.com>2014-04-29 12:03:30 +0200
commit596487e5bca4fcd23230527e55e07a2d20a87347 (patch)
tree7cd7cbf76a85a62dd87517a72d3562edf60ba38f
parentdd805353fa1624d26735447d61c8bbdbcffd0025 (diff)
downloadoslo-serialization-596487e5bca4fcd23230527e55e07a2d20a87347.tar.gz
On Python <= 2.6, use simplejson if available
Until Python 2.7, stdlib json module was not boosted with a C extension, meaning bad performance. Try to use simplejson module if available. RHEL 6.5 is one of the platforms that still ship Python 2.6. The original idea of the patch belongs to Miguel Angel Ajo Pelayo @ mangelajo@redhat.com Change-Id: Ib3dc0b713ed90396919feba018772243b3b9c90f Closes-Bug: 1314129
-rw-r--r--openstack/common/jsonutils.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/openstack/common/jsonutils.py b/openstack/common/jsonutils.py
index 765e689..86b2987 100644
--- a/openstack/common/jsonutils.py
+++ b/openstack/common/jsonutils.py
@@ -35,7 +35,17 @@ import datetime
import functools
import inspect
import itertools
-import json
+import sys
+
+if sys.version_info < (2, 7):
+ # On Python <= 2.6, json module is not C boosted, so try to use
+ # simplejson module if available
+ try:
+ import simplejson as json
+ except ImportError:
+ import json
+else:
+ import json
import six
import six.moves.xmlrpc_client as xmlrpclib