From 88f9bbb6e643472f9218ea88e19afc57ffab025b Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 29 Apr 2014 16:23:46 +0200 Subject: [PATCH] Synced jsonutils from oslo-incubator The sync includes change that drastically enhances performance on Python 2.6 with fresh simplejson library installed. The latest commit in oslo-incubator: - 732bdb6297eb9de81667f7713ebcb1ccc2ee45a7 Change-Id: Ib3dc0b713ed90396919feba018772243b3b9c90f Closes-Bug: 1314129 --- neutron/openstack/common/jsonutils.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/neutron/openstack/common/jsonutils.py b/neutron/openstack/common/jsonutils.py index d4a764b02dd..ba2437dc26f 100644 --- a/neutron/openstack/common/jsonutils.py +++ b/neutron/openstack/common/jsonutils.py @@ -35,18 +35,20 @@ import datetime import functools import inspect import itertools -import json -try: - import xmlrpclib -except ImportError: - # NOTE(jaypipes): xmlrpclib was renamed to xmlrpc.client in Python3 - # however the function and object call signatures - # remained the same. This whole try/except block should - # be removed and replaced with a call to six.moves once - # six 1.4.2 is released. See http://bit.ly/1bqrVzu - import xmlrpc.client as xmlrpclib +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 from neutron.openstack.common import gettextutils from neutron.openstack.common import importutils