Skip to main content

DRF Accelerator

🚀 Turbocharge your Django REST Framework (DRF) list serialization by replacing Python's hot loop with a high-performance Rust extension.

PyPI version License: MIT

DRF Accelerator addresses one of the most common performance bottlenecks in Django applications: returning large lists of data. By offloading the innermost object-to-dict conversion loop to a Rust module (via PyO3), it bypasses the heavy Python interpreter overhead, resulting in massive throughput gains for your API endpoints.


💡 Why DRF Accelerator?

If you've ever profiled a DRF application returning standard many=True responses, you know that creating hundreds or thousands of dictionaries in pure Python is exceptionally slow.

The Solution:
We swap DRF's standard ListSerializer with a custom-built Rust implementation (FastListSerializer).

The Guarantees:

  • Zero API breakage: You still get exactly the same standard DRF serializer.data structures.
  • Zero logic changes: You don't need to rewrite your serializers into .values() queries or change how you query your database.
  • Minimal adoption effort: Add exactly one mixin to your existing serializer classes.

⚡ Performance

The largest speedups occur on list responses (many=True) containing 100s to 10,000s of items, particularly when the fields are primitive types (str, int, float, bool, None).

Because benchmarks are highly workload-dependent, this repository includes tooling for you to test the gains directly against your own hardware:

  • Micro-benchmarks: Tests the pure Rust loop vs pure Python loop.
  • End-to-End benchmarks: Tests an actual DRF request cycle.

To run the benchmarks locally (requires cloning the repository):

cd drf_accelerator
pytest benchmarks/ -v --benchmark-only

📦 Installation

Requirements:

  • Python 3.10 – 3.13
  • Django REST Framework >= 3.12

Install directly from PyPI:

pip install drf-accelerator

Note: This package ships with pre-built binary wheels for major platforms (Linux, macOS, Windows). If your specific architecture isn't covered, pip will automatically attempt to compile it from source (which requires a standard Rust toolchain).


🚦 Quickstart & Usage

DRF Accelerator is designed to be completely unobtrusive. To accelerate a serializer, simply inherit from FastSerializationMixin as your first base class.

from rest_framework import serializers
from drf_accelerator import FastSerializationMixin

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

When you use this serializer for list endpoints (many=True), the Rust accelerator automatically takes over!

# The FastListSerializer written in Rust will process this entire queryset
serializer = MyModelSerializer(queryset, many=True)
data = serializer.data 

🔍 How It Works & Supported Features

Under the hood, FastSerializationMixin overrides the many_init method to return our Rust-backed FastListSerializer.

Fast-Path Supported Types

The Rust extension has deeply optimized zero-overhead "fast paths" for standard conversions:

  • str, int, float, bool, None
  • datetime, date, time
  • uuid.UUID, decimal.Decimal

Universal Fallback

For any deeply custom fields (or object types the Rust layer doesn't explicitly know how to fast-path), the serializer gracefully falls back to calling the standard DRF field’s to_representation(value) method. It will never break your data structure.

Supported Field Configurations

  • Standard fields (CharField, IntegerField, etc.)
  • Dotted sources (source="author.user.email")
  • SerializerMethodField
  • Nested Serializers

⚠️ Scope & Limitations

  • Read-Only Focus: This accelerator strictly improves output serialization. It does not speed up incoming data parsing, validation, or saving (.is_valid() or .save()).
  • List Serialization Only: It accelerates iterables (many=True). Single-object serialization (many=False) remains unchanged because the overhead of calling the Rust extension outweighs the benefits for a single dictionary.
  • Fallbacks cause slowdowns: Relying heavily on manual MethodFields or custom data types that require the Python fallback will naturally reduce your overall speedup multiplier, though it will still be faster than native DRF.

Metadata

Release files for drf-accelerator 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drf-accelerator 0.1.2
File Size Uploaded
drf_accelerator-0.1.2.tar.gz 13.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for drf-accelerator 0.1.2
File
drf_accelerator-0.1.2-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
drf_accelerator-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
drf_accelerator-0.1.2-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
drf_accelerator-0.1.2-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
drf_accelerator-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
drf_accelerator-0.1.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
drf_accelerator-0.1.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
drf_accelerator-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
drf_accelerator-0.1.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
drf_accelerator-0.1.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
drf_accelerator-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
drf_accelerator-0.1.2-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 3.0 MB

Release files / drf_accelerator-0.1.2.tar.gz

Download URL drf_accelerator-0.1.2.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8d94229284d318907a3b8f88f95b7e7b792a162d3856c3e3e674efefad21e8bf
BLAKE2b-256 checksum
How to use checksums
3e4c1b4b2b28d3759e307fdcb6c8d4411659b6afe68964abf7c6edf411688662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp313-cp313-win_amd64.whl

Download URL drf_accelerator-0.1.2-cp313-cp313-win_amd64.whl
Size 168.2 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
1c94ecbc89ae2881251cf299c687e7cdd4d9e3c488a5a0a54d75d2a83883089a
BLAKE2b-256 checksum
How to use checksums
562c3962a6dd1debbf34630eaefb14046ddca713d470b8f1c3267320a068116a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL drf_accelerator-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 314.7 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
524c9936a3671a44115e25d066fcfe5714fac73ede3905aa4aac2a70b58412d6
BLAKE2b-256 checksum
How to use checksums
555895003ea2b2227bff56b7a0f84d16a9bdd84f2073e2c94b92baecf7c36645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp313-cp313-macosx_11_0_arm64.whl

Download URL drf_accelerator-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Size 271.4 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a6c7094fc56962dede6e30ec1ce16bc449f3baffb6363872e6aaf545fefaaf1d
BLAKE2b-256 checksum
How to use checksums
bb013da9694c2e7282ba30bb8f9f9912240d62725a17b56a3303fb847c0a404e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp312-cp312-win_amd64.whl

Download URL drf_accelerator-0.1.2-cp312-cp312-win_amd64.whl
Size 167.9 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
27271ded49de760b0e6f8ba670a66764bd501173c76e9d86608ea78aec76a334
BLAKE2b-256 checksum
How to use checksums
d5dde3b909206e144b5e4fa75857be05854631a379200c54cfbcbdf71f3c6da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL drf_accelerator-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 314.8 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1e6c97fda66256c4735df9719cfd2394ea25a6a2d2feb02fa3b250df73a7da0d
BLAKE2b-256 checksum
How to use checksums
379fdd7a86f39b95e67efdb2e4927a4427eab1553ea95c3702ed712bc20cdb42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL drf_accelerator-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Size 271.2 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
566eea8bba4654ef19f999f5f3c5c310c141605124f5584145254dbb64319866
BLAKE2b-256 checksum
How to use checksums
cc958715150dcf1bfe8745105674c9ed74bd08244293cfd9f35e1e02d9427f7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp311-cp311-win_amd64.whl

Download URL drf_accelerator-0.1.2-cp311-cp311-win_amd64.whl
Size 167.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
9cd0fd94cfcbe7a3ce58486c1895380f9074be907e3b8784ed122efc510f7439
BLAKE2b-256 checksum
How to use checksums
af3efbf777e50e6515ae88286ee37b395b81ab4e5a30c72c421d4d56742af8cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL drf_accelerator-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 314.4 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
acf4042f8659d991b770469cd575d32332502c486782aefeced5ed22e86dfaa5
BLAKE2b-256 checksum
How to use checksums
1901889dd11ac2003cb2ba42934770baab7b43a20c6a8e68992b8b7a0e9b41ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL drf_accelerator-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Size 274.3 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e9ed9b516358b0d8d3ac3842cca43aeaa2c1387444fc04270ac5afbb74c1f316
BLAKE2b-256 checksum
How to use checksums
d8e3dfd796630ea3f61507dc0221e04d1b50af007b1bdb940f1b0d1d7b20370e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp310-cp310-win_amd64.whl

Download URL drf_accelerator-0.1.2-cp310-cp310-win_amd64.whl
Size 167.5 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
bbd522dbb7a36b3001fd9d0ef9c935c2d4c2a1f02f2e1dd0aab1d01d2b086984
BLAKE2b-256 checksum
How to use checksums
f5ffefb554727ce9bde16dc4941eed8092dda12f5005f06ec44dff7e9b69dabd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL drf_accelerator-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 314.5 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5364782af39d2fa9a58ded62c3425ccb7c7c54a1a7e87517fdaf75255c8f744c
BLAKE2b-256 checksum
How to use checksums
aca0b17f3fb11ad465341e9a08d1e08751730f647876e73653e8df094812e265
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release files / drf_accelerator-0.1.2-cp310-cp310-macosx_11_0_arm64.whl

Download URL drf_accelerator-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Size 274.6 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4d2a2a1fb5b316d8646a72559939aebd19ecacffd52d6589f34b89d4da9dd237
BLAKE2b-256 checksum
How to use checksums
b2db5187436905db83eefe12ad2bf6f5570d64a8660820f8047f309ccbf0bfbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

13 release files

0.1.1

12 release files

0.1.0

12 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page