Django Rest Framework UJSON Renderer
Django Rest Framework renderer using ujson
Installation
pip install drf_ujson2
You can then set the UJSONRenderer class as your default renderer in your settings.py
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'drf_ujson.renderers.UJSONRenderer',
),
...
}
Benchmarks
This is on average 2.3x faster than the default JSON Serializer.
import timeit
setup = '''
from proposals.models import Proposal
from proposals.serializers import ProposalSerializer
from rest_framework.renderers import JSONRenderer
from drf_ujson.renderers import UJSONRenderer
proposals = Proposal.objects.all()
serialized = ProposalSerializer(proposals, many=True).data
'''
stdlib_test = '''
JSONRenderer().render(serialized)
'''
ujson_test = '''
UJSONRenderer().render(serialized)
'''
stdlib_result = timeit.repeat(stdlib_test, setup=setup, number=1, repeat=10)
ujson_result = timeit.repeat(ujson_test, setup=setup, number=1, repeat=10)
print stdlib_result
print sum(stdlib_result) / 10
print ujson_result
print sum(ujson_result) / 10
# stdlib results
[
0.004502058029174805,
0.004289865493774414,
0.006896018981933594,
0.0048198699951171875,
0.004084110260009766,
0.007154941558837891,
0.003937959671020508,
0.004029035568237305,
0.004770040512084961,
0.004539966583251953
]
# avg
0.00490238666534
# ujson results
[
0.0016620159149169922,
0.001817941665649414,
0.0015261173248291016,
0.0040950775146484375,
0.0021469593048095703,
0.001798868179321289,
0.001569986343383789,
0.0019931793212890625,
0.0017120838165283203,
0.001814126968383789
]
# avg
0.00201363563538
Metadata
Release files for drf-ujson2 1.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drf_ujson2-1.8.0.tar.gz | 4.6 kB | Without provenance | Details for drf_ujson2-1.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_ujson2-1.8.0-py3-none-any.whl | Python 3 | none | any | Details for drf_ujson2-1.8.0-py3-none-any.whl |
Total release size: 9.6 kB
Release files / drf_ujson2-1.8.0.tar.gz
| Download URL | drf_ujson2-1.8.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b42cade02138cc1ddb159e4a91ff7115929d3066242bffc623ade9b3a525d70
|
|
BLAKE2b-256 checksum How to use checksums |
ea9b6255e579d0903f2c1a50c77a7e3af8e563cd9f116af21ac6e7690eec019c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / drf_ujson2-1.8.0-py3-none-any.whl
| Download URL | drf_ujson2-1.8.0-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a6e32f687e29394002d8bec91e8a9ab44251564888fa5d907c737bc2f62ce42
|
|
BLAKE2b-256 checksum How to use checksums |
7cdd8f9f458de766c6e83912058c1fc47946a5cba34a8fee9fe7d9974c7d36b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Security for drf-ujson2 1.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.