From fcda567f8cdae741e6cecd491a5df91bf2909c6e Mon Sep 17 00:00:00 2001 From: Rahiel Kasim Date: Fri, 26 Aug 2016 09:40:46 +0200 Subject: [PATCH] use ujson as JSON en/decoder if available --- telegram/base.py | 6 +++++- telegram/utils/request.py | 5 ++++- telegram/utils/webhookhandler.py | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/telegram/base.py b/telegram/base.py index 4123d1412..6d0fe7ff1 100644 --- a/telegram/base.py +++ b/telegram/base.py @@ -18,7 +18,11 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """Base class for Telegram Objects.""" -import json +try: + import ujson as json +except ImportError: + import json + from abc import ABCMeta diff --git a/telegram/utils/request.py b/telegram/utils/request.py index 696e6d95c..5a0845f28 100644 --- a/telegram/utils/request.py +++ b/telegram/utils/request.py @@ -18,7 +18,10 @@ # along with this program. If not, see [http://www.gnu.org/licenses/]. """This module contains methods to make POST and GET requests""" -import json +try: + import ujson as json +except ImportError: + import json import os import socket import logging diff --git a/telegram/utils/webhookhandler.py b/telegram/utils/webhookhandler.py index 3abd9a2b3..14c60d3a8 100644 --- a/telegram/utils/webhookhandler.py +++ b/telegram/utils/webhookhandler.py @@ -3,7 +3,10 @@ import logging from telegram import Update from future.utils import bytes_to_native_str from threading import Lock -import json +try: + import ujson as json +except ImportError: + import json try: import BaseHTTPServer except ImportError: