Use ujson instead of json for parsing messages

ujson is simply faster than json :)

Change-Id: I1f33dda01cc4ee09f0bae1c2d2a33fbda65c1cac
This commit is contained in:
Jakub Wachowski 2017-08-08 13:52:59 +02:00
parent 5f168778c6
commit 16d8e69a4c
6 changed files with 11 additions and 6 deletions

View File

@ -12,7 +12,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import ujson as json
from cassandra import query
from oslo_log import log

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import hashlib
import json
import ujson as json
from cassandra import query
from oslo_log import log

View File

@ -12,7 +12,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import ujson as json
from oslo_log import log

View File

@ -28,12 +28,17 @@ def escape_tag(tag):
u"=", u"\\="
)
def get_unicode(data):
if PY2:
return unicode(data)
if isinstance(data, unicode):
return data
else:
return data.decode('utf-8')
else:
return str(data)
def escape_value(value):
return u"\"{0}\"".format(
get_unicode(value).replace(

View File

@ -12,7 +12,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import ujson as json
from oslo_log import log

View File

@ -12,7 +12,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import ujson as json
def parse_measurement_message(message):