From a6b2aecf3a75e4bdef493b645112a7944bced1e1 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 29 Apr 2014 12:03:30 +0200 Subject: [PATCH] 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 --- openstack/common/jsonutils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openstack/common/jsonutils.py b/openstack/common/jsonutils.py index 765e68939..86b2987da 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