Skip to content

Commit

Permalink
Take 2 at trying orjson (#11786)
Browse files Browse the repository at this point in the history
* Revert "Revert "Use orjson for our json renderer (#11675)" (#11697)"

This reverts commit 6d39d8d.

* Upgrade orjson
  • Loading branch information
dstufft authored Jul 8, 2022
1 parent d1579df commit 6b508b7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions requirements/main.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ kombu[sqs]~=5.2.4 # https://github.com/celery/celery/issues/7070
mistune
msgpack
natsort
orjson
packaging>=15.2
paginate>=0.5.2
paginate_sqlalchemy
Expand Down
40 changes: 40 additions & 0 deletions requirements/main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,46 @@ natsort==8.1.0 \
--hash=sha256:c7c1f3f27c375719a4dfcab353909fe39f26c2032a062a8c80cc844eaaca0445 \
--hash=sha256:f59988d2f24e77b6b56f8a8f882d5df6b3b637e09e075abc67b486d59fba1a4b
# via -r requirements/main.in
orjson==3.7.7 \
--hash=sha256:0033c7279f0ffa2720d72a6234a1d22c86c13bf5217a99c5ba523a0aebb27b75 \
--hash=sha256:092fde5b1768ca68af0d3764746e93b4b7200050fdd9c1ea044fd106e2379951 \
--hash=sha256:2850cf49537c246000f5f89555d6fb7042bb4612214605a60bea89cbe0add213 \
--hash=sha256:2c43fd0317a7114e617f5b8aefd0d0a61b387927a1914b79ebd0d1235c658f5b \
--hash=sha256:313bcab8cd59d61e12bbf76a9b5f3eaf50848e3fb370a54f712ad3e3e0a48165 \
--hash=sha256:3e9b1f19b408199af4d4ad590f6935ba77342a3fe1d64cbbfe428025a03a2405 \
--hash=sha256:3f9fbf760c6612d08a4ea873e4fab1e657f826834deda58c2ba1406ef150b1b6 \
--hash=sha256:559f40a91bfde23137e107f2f8baaf0bef35e066d0b35dcf4e1dac8bc83a05b3 \
--hash=sha256:5c8141895c8b0a8b4d0bc1879d1c1e3ec3f7d7e29e0bd8a0146ef3f9cf13c325 \
--hash=sha256:5f20d0d48335262ca3695f98599446bf5ca8825193d1f4bf6eb08fb0c414befa \
--hash=sha256:5ff90b571023787dcbb504a1695ad137149df30d213128b1aa02fc82dd12a526 \
--hash=sha256:6340e57fece4fa0eebd1e5c48e2c844b329491d97bfe6843149eb45365ff837a \
--hash=sha256:657ce6d735dc3a6fba5043d831e769698db849915d581dd4d1e62fcc2eaed876 \
--hash=sha256:6a743e05de78758f9ff81a4e705e6226b06a5f8abba63b39cb0f56926c2045c5 \
--hash=sha256:6e5ea0fcf3452cd19ad34b37ca6279c4395b859c77fe1cf7e26d31a3e6ebafd5 \
--hash=sha256:6fbf29bb7897d345bd0120c466cd923c70a5d661144221457cbed637f4c93d1b \
--hash=sha256:70cffd48faafabdd7e42f35e38731c43200d525fdbabc587b1e2aa731d182f85 \
--hash=sha256:7f80825fa7a48c4abcd636d3c182a71ad1cb548db66b8aafad50dfd328c29ae0 \
--hash=sha256:891c0f2cb44beafa911cf7e15165dee8b8acaa5b48a75abaf37d529e1de68344 \
--hash=sha256:8c30ad18fad795690527b030cfed3e8402ebe3a15e7a1a779a00acc0b3587e89 \
--hash=sha256:8da26f1fd335e466e79779571326679b179bb7cf3cce9750bf9c1077e9298a6f \
--hash=sha256:9f7f420ab7efde90c7277e92dccf217b4bac628b044fdc857888cdba23126214 \
--hash=sha256:a34002a6b6eb105d3ac493368f0a8911ab8e5f005282d43cc75912bbbdf50734 \
--hash=sha256:aee6715db93b3d743adc69f55ed20df6a782b5e354d26a7817e507e2bd6d2231 \
--hash=sha256:b6a6d00e917e1844d3a9b6ed68d31f824d98e1e4a3578618dd146db58b5d901b \
--hash=sha256:ba48e06659c43ed6658f203893b74b4e8392231959bcb2421fdde39eca62520c \
--hash=sha256:c1e8489d50bb0cffb5ccb70c3459f79dee1aeb997abfd97751d3862b32bce412 \
--hash=sha256:ce3acc906a6aa7923bc7c78472196b2b7cf7c160aff01946984d51fcde9e9483 \
--hash=sha256:d8f1aa7fd08f001b5f13d0c8c862609bb7de7291b256630f97590eb7c78d2dda \
--hash=sha256:d9af18e8200b500585627414ec7b0806b5b569a318d6c84447afb02e7eae5bfa \
--hash=sha256:dbf716120886776706781c2c05ebbc254355e384bfe387b76ca07ee97da6fbfc \
--hash=sha256:e8bfad95df150d95ca67a4484d9f56e2bd0a932a5eb4635bbb5cd45130ca9251 \
--hash=sha256:ea0f6da9089e155acf234c0cd0883f84812547174be8d0fef478bce2b00bd6f9 \
--hash=sha256:ea3eaa8823bbbaae7af9669ca68b0e0bd794ee0938900d73f5f321fb13bb5ab5 \
--hash=sha256:ead2c1dce61c2e3bad31af48c2dccbbc23c55bbe70870af437203a7c4b229bae \
--hash=sha256:ee2cd3ac6283832d93085910df8367a469bd9dbfafeb8d4dc8c5cc8648bf965c \
--hash=sha256:f0c512efeee1fb94426b1e4c64f07c4af5eec08b96cf4835c3a05ad395e0b83a \
--hash=sha256:fa9451779dba8546962bc02ce2aeed9de6e069f7101f8db2784beaf71ede4dd0
# via -r requirements/main.in
packaging==21.3 \
--hash=sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb \
--hash=sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from unittest import mock

import orjson
import pretend
import pytest

Expand Down Expand Up @@ -443,7 +444,10 @@ def __init__(self):
]

assert json_renderer_cls.calls == [
pretend.call(sort_keys=True, separators=(",", ":"))
pretend.call(
serializer=orjson.dumps,
option=orjson.OPT_SORT_KEYS | orjson.OPT_APPEND_NEWLINE,
)
]

assert xmlrpc_renderer_cls.calls == [pretend.call(allow_none=True)]
Expand Down
9 changes: 8 additions & 1 deletion warehouse/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import shlex

import orjson
import transaction

from pyramid import renderers
Expand Down Expand Up @@ -451,7 +452,13 @@ def configure(settings=None):

# We want to configure our JSON renderer to sort the keys, and also to use
# an ultra compact serialization format.
config.add_renderer("json", renderers.JSON(sort_keys=True, separators=(",", ":")))
config.add_renderer(
"json",
renderers.JSON(
serializer=orjson.dumps,
option=orjson.OPT_SORT_KEYS | orjson.OPT_APPEND_NEWLINE,
),
)

# Configure retry support.
config.add_settings({"retry.attempts": 3})
Expand Down

0 comments on commit 6b508b7

Please sign in to comment.