Skip to content

Commit fcda567

Browse files
committed
use ujson as JSON en/decoder if available
1 parent ffff093 commit fcda567

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

telegram/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""Base class for Telegram Objects."""
2020

21-
import json
21+
try:
22+
import ujson as json
23+
except ImportError:
24+
import json
25+
2226
from abc import ABCMeta
2327

2428

telegram/utils/request.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
# along with this program. If not, see [http://www.gnu.org/licenses/].
1919
"""This module contains methods to make POST and GET requests"""
2020

21-
import json
21+
try:
22+
import ujson as json
23+
except ImportError:
24+
import json
2225
import os
2326
import socket
2427
import logging

telegram/utils/webhookhandler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from telegram import Update
44
from future.utils import bytes_to_native_str
55
from threading import Lock
6-
import json
6+
try:
7+
import ujson as json
8+
except ImportError:
9+
import json
710
try:
811
import BaseHTTPServer
912
except ImportError:

0 commit comments

Comments
 (0)