Skip to content

Commit 9926ef5

Browse files
VincentRPSpre-commit-ci[bot]Lulalaby
authored
refactor: replace orjson support with msgspec (#2170)
* refactor: replace orjson support with msgspec * style(pre-commit): auto fixes from pre-commit.com hooks * chore: add to changelog --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lala Sabathil <[email protected]>
1 parent 6ccfd7f commit 9926ef5

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ These changes are available on the `master` branch, but have not yet been releas
9494
([#2087](https://github.com/Pycord-Development/pycord/pull/2087))
9595
- Typehinted `command_prefix` and `help_command` arguments properly.
9696
([#2099](https://github.com/Pycord-Development/pycord/pull/2099))
97+
- Replace `orjson` support with `msgspec` support.
98+
([#2170](https://github.com/Pycord-Development/pycord/pull/2170))
9799

98100
### Removed
99101

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Optional Packages
8585

8686
* `PyNaCl <https://pypi.org/project/PyNaCl/>`__ (for voice support)
8787
* `aiodns <https://pypi.org/project/aiodns/>`__, `brotlipy <https://pypi.org/project/brotlipy/>`__, `cchardet <https://pypi.org/project/cchardet/>`__ (for aiohttp speedup)
88-
* `orjson <https://pypi.org/project/orjson/>`__ (for json speedup)
88+
* `msgspec <https://pypi.org/project/msgspec/>`__ (for json speedup)
8989

9090
Please note that while installing voice support on Linux, you must install the following packages via your preferred package manager (e.g. ``apt``, ``dnf``, etc) BEFORE running the above commands:
9191

discord/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
from .errors import HTTPException, InvalidArgument
6767

6868
try:
69-
import orjson
69+
import msgspec
7070
except ModuleNotFoundError:
71-
HAS_ORJSON = False
71+
HAS_MSGSPEC = False
7272
else:
73-
HAS_ORJSON = True
73+
HAS_MSGSPEC = True
7474

7575

7676
__all__ = (
@@ -662,12 +662,12 @@ def _bytes_to_base64_data(data: bytes) -> str:
662662
return fmt.format(mime=mime, data=b64)
663663

664664

665-
if HAS_ORJSON:
665+
if HAS_MSGSPEC:
666666

667667
def _to_json(obj: Any) -> str: # type: ignore
668-
return orjson.dumps(obj).decode("utf-8")
668+
return msgspec.json.encode(obj).decode("utf-8")
669669

670-
_from_json = orjson.loads # type: ignore
670+
_from_json = msgspec.json.decode # type: ignore
671671

672672
else:
673673

requirements/speed.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
orjson>=3.5.4
1+
msgspec~=0.17.0
22
aiohttp[speedups]

0 commit comments

Comments
 (0)