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
This commit is contained in:
Ihar Hrachyshka 2014-04-29 12:03:30 +02:00
parent 4ff3db607d
commit a6b2aecf3a
1 changed files with 11 additions and 1 deletions

View File

@ -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