All Projects → Amertz08 → drf_ujson2

Amertz08 / drf_ujson2

Licence: MIT license
JSON parser and renderer using ujson for Django Rest Framework

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to drf ujson2

formica
A discord bot that collects and analyzes form data
Stars: ✭ 20 (-31.03%)
Mutual labels:  django-rest-framework
Deep-learning-model-deploy-with-django
Serving a keras model (neural networks) in a website with the python Django-REST framework.
Stars: ✭ 76 (+162.07%)
Mutual labels:  django-rest-framework
DjangoUnboxed
Production ready django based starter kit
Stars: ✭ 67 (+131.03%)
Mutual labels:  django-rest-framework
react-tutorial
A react-tutorial
Stars: ✭ 99 (+241.38%)
Mutual labels:  django-rest-framework
bk-user
蓝鲸用户管理是蓝鲸智云提供的企业组织架构和用户管理解决方案,为企业统一登录提供认证源服务。
Stars: ✭ 31 (+6.9%)
Mutual labels:  django-rest-framework
drf-action-serializer
A serializer for the Django Rest Framework that supports per-action serialization of fields.
Stars: ✭ 48 (+65.52%)
Mutual labels:  django-rest-framework
drf-jwt-example
Code samples of the tutorial "How to Use JWT Authentication with Django REST Framework"
Stars: ✭ 31 (+6.9%)
Mutual labels:  django-rest-framework
machado
This repository provides users with a framework to store, search and visualize biological data.
Stars: ✭ 18 (-37.93%)
Mutual labels:  django-rest-framework
Footprint
Bluetooth Beacon 을 활용한 장소 기반 추억 기록 및 공유 서비스
Stars: ✭ 24 (-17.24%)
Mutual labels:  django-rest-framework
CloudCV
☁️ CloudCV Website
Stars: ✭ 53 (+82.76%)
Mutual labels:  django-rest-framework
ujson drf
JSON Renderer and Parser for Django Rest Framework using the ultra fast json (in C).
Stars: ✭ 14 (-51.72%)
Mutual labels:  django-rest-framework
vstutils
Small framework for easy generates web-applications (SPA or Single Page Application).
Stars: ✭ 39 (+34.48%)
Mutual labels:  django-rest-framework
django-learning-pathway
(Currently in development) Learning pathways for learning Django.
Stars: ✭ 35 (+20.69%)
Mutual labels:  django-rest-framework
django-rest-witchcraft
Django REST Framework integration with SQLAlchemy
Stars: ✭ 38 (+31.03%)
Mutual labels:  django-rest-framework
filtermapbackend
FilterMapBackend for django-rest-framework
Stars: ✭ 16 (-44.83%)
Mutual labels:  django-rest-framework
studyportal-nexus
Backend API for studyportal
Stars: ✭ 24 (-17.24%)
Mutual labels:  django-rest-framework
drf-registration
Simple user registration package based on Django Rest Framework. DRF Registration - The easy way to generate registration RESTful APIs
Stars: ✭ 32 (+10.34%)
Mutual labels:  django-rest-framework
csf
ArmourBird CSF - Container Security Framework
Stars: ✭ 48 (+65.52%)
Mutual labels:  django-rest-framework
Auto-DL
Auto-DL helps you make Deep Learning models without writing a single line of code and giving as little input as possible.
Stars: ✭ 165 (+468.97%)
Mutual labels:  django-rest-framework
Malicious-Urlv5
A multi-layered and multi-tiered Machine Learning security solution, it supports always on detection system, Django REST framework used, equipped with a web-browser extension that uses a REST API call.
Stars: ✭ 35 (+20.69%)
Mutual labels:  django-rest-framework

Django Rest Framework UJSON Renderer

Build Status PyPi - Version PyPI - Python Version PyPI - Django Version PyPI - Downloads Code style: Black

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',
    ),
    ...
}

Also you can set the UJSONParser class as your default parser in your settings.py

REST_FRAMEWORK = {
    'DEFAULT_PARSER_CLASSES': (
        'drf_ujson.parsers.UJSONParser',
    ),
    ...
}

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].