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

Conflicts:
	openstack/common/jsonutils.py

Change-Id: Ib3dc0b713ed90396919feba018772243b3b9c90f
Closes-Bug: 1314129
(cherry picked from commit a6b2aecf3a)
This commit is contained in:
Ihar Hrachyshka 2014-04-29 12:03:30 +02:00
parent 6a290f5ded
commit 7e3c27fb50
1 changed files with 12 additions and 1 deletions

View File

@ -38,7 +38,18 @@ 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
try:
import xmlrpclib
except ImportError: