Skip to main content

A high-performance Rust-backed accelerator for Django Rest Framework.

Project description

DRF Accelerator

[!CAUTION] Experimental / Under Development This project is currently an experiment to improve DRF performance using Rust. It is NOT production-ready and has strict scope limitations.

A high-performance Rust-backed accelerator for Django Rest Framework.

Performance Benchmark

Method Time (10k items) Speedup
Standard DRF 0.3288s 1x
drf-accelerator 0.0389s ~8.45x

Benchmark run on 10,000 Product models with 5 primitive fields in the examples project.

Installation & Setup

For Users (Stable)

Currently, the package is in early development. To install it from source:

  1. Prerequisites: Ensure you have Rust installed.
  2. Clone the repository:
    git clone https://github.com/p-r-a-v-i-n/drf-accelerator.git
    cd drf-accelerator
    
  3. Build and Install:
    pip install -e .
    

For Developers (Try it out)

If you want to run the benchmarks yourself:

  1. Build the extension:

    cd drf_accelerator
    maturin develop --release
    cd ..
    
  2. Setup and Run Benchmark:

    cd examples
    python manage.py migrate
    python bench.py
    

Usage

Simply inherit from FastSerializationMixin in your ModelSerializer:

from drf_accelerator import FastSerializationMixin
from rest_framework import serializers

class MySerializer(FastSerializationMixin, serializers.ModelSerializer):
    class Meta:
        model = MyModel
        fields = ["id", "title", "author", "is_published"]

Limitations (Strict)

To maintain high performance and safety, the following are not supported:

  • Dotted Sources: source="user.profile.age" will error.
  • Nested Serializers: Cannot be used inside an accelerated serializer.
  • Method Fields: SerializerMethodField is not supported.
  • Non-Primitives: Only int, str, float, bool, and None are supported. Non-primitive types (like Decimal or Date) will currently trigger a TypeError.

How it works

The Mixin swaps the standard DRF ListSerializer for a FastListSerializer that offloads the object-to-dict conversion loop to a Rust extension using PyO3. This significantly reduces Python interpreter overhead for large list responses.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf_accelerator-0.1.0a1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

drf_accelerator-0.1.0a1-cp313-cp313-win_amd64.whl (165.5 kB view details)

Uploaded CPython 3.13Windows x86-64

drf_accelerator-0.1.0a1-cp313-cp313-manylinux_2_34_x86_64.whl (228.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

drf_accelerator-0.1.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

drf_accelerator-0.1.0a1-cp313-cp313-macosx_11_0_arm64.whl (269.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

drf_accelerator-0.1.0a1-cp312-cp312-win_amd64.whl (165.6 kB view details)

Uploaded CPython 3.12Windows x86-64

drf_accelerator-0.1.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

drf_accelerator-0.1.0a1-cp312-cp312-macosx_11_0_arm64.whl (269.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

drf_accelerator-0.1.0a1-cp311-cp311-win_amd64.whl (165.0 kB view details)

Uploaded CPython 3.11Windows x86-64

drf_accelerator-0.1.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

drf_accelerator-0.1.0a1-cp311-cp311-macosx_11_0_arm64.whl (273.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

drf_accelerator-0.1.0a1-cp310-cp310-win_amd64.whl (165.3 kB view details)

Uploaded CPython 3.10Windows x86-64

drf_accelerator-0.1.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

drf_accelerator-0.1.0a1-cp310-cp310-macosx_11_0_arm64.whl (273.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file drf_accelerator-0.1.0a1.tar.gz.

File metadata

  • Download URL: drf_accelerator-0.1.0a1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for drf_accelerator-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 a65c94d2b60129f91e99dbf821412d4c0f5707e27e869e98ccc7200ff5300bcc
MD5 838bf081d33e2e48f20041da9fc5f6e9
BLAKE2b-256 86b08b771eae56e7cec9d583fa0c7dcc64114f2f6d36ad890c54020d5de736a4

See more details on using hashes here.

File details

Details for the file drf_accelerator-0.1.0a1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 10e64c065b42b10c25fe106ca31083cc09ba90f7f07fcdbdfb06a74ceb5cc801
MD5 e66276d3e256a051c76266f6a6548d34
BLAKE2b-256 a44af543cc2284db998d4be388026a4072dbffdedd49e85d4cfab66d88f440e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp313-cp313-win_amd64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a6553d1afa8b01a7cae96301a0374dd774b952233bf05217b63b399eda72ebb7
MD5 e45894594b3cc53374a42bdb1cb5a2a8
BLAKE2b-256 01f5c9c50dbad98125f8dd426c24d5d820d9892b60fef3a4ee95c8f066eb1926

See more details on using hashes here.

File details

Details for the file drf_accelerator-0.1.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bcece38ed6e852ba0c7326c3bcb802cc8bc3a355f7bc1556bebcd013588415df
MD5 e3e5cd03aea55385bc09d154387df21b
BLAKE2b-256 23841c60b76a7afe87f02bec5e9758ef08b1191fbc0b6f423f46e7086b7810bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e5653191e4aabe4d2be2eb8f33c1c01ce26b224c5dec0ab6dced8a98944d2c0
MD5 58e41f863a935b7b4fa82f9fc3653718
BLAKE2b-256 91def7d38f0f1c18d4c9fc64e095bf057e3a1341e2add1bcef97d53b9c2f5358

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ce9d6bc35ebebe663e53037f2690ad102970727b10962e8df343bc028384c1fe
MD5 10491530297a64a1a31e97e07b77f6cb
BLAKE2b-256 c550b9b42cde8dd2c7e04a9125541633c6c93345f3738e5c9eb94ca1e00f1853

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp312-cp312-win_amd64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bff7db30ed1f6fddc91cee7b7555af26a3e89327b01410f544ea5c0553e59923
MD5 b6fcb80272d548db00bae21f70012ba1
BLAKE2b-256 966e66da28986f683a09a771db7c353002d317321dcd9db98664e3d70e9496ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 017fb3c2d17f47ade1017e09686d74dd68bf7d350b2ad15196e6a12d4fc3ad80
MD5 698e6678e57154a4f7482b36fa4d204b
BLAKE2b-256 00ed3ca7509518d95e6aa0d8f6adc4ac29035c9877da9ed7515cc3dd29b250f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 42290d9fd1a4aad9f4ad61d84f6558949c1c61aec81355c0c838121c01f3ba3a
MD5 2da601d9fe902f6db8aff5a752ce8f82
BLAKE2b-256 0afa36aaf0c709edab72920c77b54dbb574bbf74e04dfd9dca34b82e19a78d6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp311-cp311-win_amd64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7e93237058e1b6484918a1c1359e15743912a173a3a83735243b5064475d401a
MD5 6cef1805c6966cec8f35abbb7ed480b3
BLAKE2b-256 489516653ced7aae9566917085fb3a5837cb7cbe3b0906dd164e9da80ec5130a

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0891dbfe49d04289b77491fb76a93860791719b28fd366ac381316afd325390a
MD5 9eb3ab41a12c7f88d7e5c7960afe0adf
BLAKE2b-256 0728ed9e58650f5dc66e8286a10238506dca404adb9d0081d726d59e13000cde

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f744b214d6695600b72a7c2db796c037a735fa7892a01b62899ad467a03b6771
MD5 9c9bbc748eacff5d175e87d2452b5f2e
BLAKE2b-256 9e24190c3ebb1587c1a36992e382cc39c118cc2527a36596cddce754ed3109d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp310-cp310-win_amd64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe56ec25e5309556883fe5eed15580f3e8929fcc286ae00af79aa6164897810b
MD5 82e104febf6e1d7ff149809c00abdf32
BLAKE2b-256 c4ae3554d09da1b02ae28293de95e57290e9797c943cbe357c1fe851f2cfbde1

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drf_accelerator-0.1.0a1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for drf_accelerator-0.1.0a1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 418f8e1197b2e351e0144efdfec2eaf8d6df0e5a01343a27974e4d94135248e6
MD5 a302bb32e903be49d2b8d9da3ed0dc36
BLAKE2b-256 31e728a4e558d05a612279f5a76b0d2cf8383cb84add82c6c6213455f39fdf66

See more details on using hashes here.

Provenance

The following attestation bundles were made for drf_accelerator-0.1.0a1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on p-r-a-v-i-n/drf-accelerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page