Dreaming Electric Sheep (des)
Dreaming Electric Sheep (des) is a high-performance CPython 3.13+ serving stack built on Granian RSGI. It is a ~20% tax you pay on raw Granian in exchange for startup-compiled msgspec binders, automated OpenAPI documentation, and a CLI that can inspect compiled requests (des why, des doctor, des routes).
See the 15-Minute Quickstart Tutorial and Why DES? for architectural trade-offs and comparisons with raw Granian, Litestar, and FastAPI.
🔮 Installation
pip install "dreaming-electric-sheep[standard]"
[standard] provides the complete runtime: granian (RSGI), typer, rich, msgspec, Jinja2, and uvloop (Unix).
🌌 The 3-Minute Hook: See the Compiled Request
1. Scaffold and Run
des new demo -t api && cd demo
des dev
2. Structured 422 Validation Errors (FastAPI-Compatible)
curl -X POST http://127.0.0.1:8000/api/items \
-H "Content-Type: application/json" \
-d '{"name": "Widget", "price": "invalid"}'
{
"detail": [
{
"loc": ["body", "price"],
"msg": "Expected `float`, got `str`",
"type": "validation_error"
}
]
}
3. Inspect the Compiled Request Pipeline (des why)
des why POST /api/items
Inspect route matching, parameter binders, and handler dispatch directly:
Route: POST /api/items
Handler: demo.app:create_item
Binders:
• data: FromJSON[CreateItemInput] (pre-compiled msgspec decoder)
OpenAPI: Documented in /openapi.json (schema: CreateItemInput)
4. Interactive OpenAPI 3.0 Documentation
Scalar UI is served automatically at http://127.0.0.1:8000/docs reading /openapi.json.
💎 Quick Start
from des import Application, get, post
from msgspec import Struct
# Fast schema-validated msgspec Struct
class CreateItemInput(Struct):
name: str
price: float
tags: list[str] = []
app = Application()
@get("/hello")
def hello():
return {"message": "Do electric sheep dream of high throughput?"}
@post("/api/items")
def create_item(data: CreateItemInput):
# Ingested and validated via pre-compiled msgspec decoder
return {"status": "created", "item": data}
Start the application:
des dev
🧊 Core Architecture & Serving Model
Dreaming Electric Sheep focuses on stripping overhead between the Rust transport layer and Python application code:
- Granian RSGI Transport: Direct
__rsgi__entrypoint with native request/response passing, bypassing ASGI message loop overhead. cdefExtension Types:Request,Response,Header, andRouteMatchare pure Cython classes with fixed C struct offsets (zero__dict__overhead).- C Object Freelists:
acquire_requestandrelease_requestrecycle request and response objects across HTTP lifecycles to minimize heap allocations. - Pre-Compiled Type Decoders:
msgspecdecoders are compiled at startup during route registration, eliminating dynamic reflection in the request path. - Direct Inspection CLI:
des why,des routes, anddes checkgive full visibility into the compiled routing table and parameter binders.
📗 OpenAPI 3.0 & Interactive UIs
Dreaming Electric Sheep automatically generates OpenAPI 3.0 documentation from type annotations (msgspec.Struct, dataclasses, Pydantic, Python typing) and docstrings.
from des import Application, get
from dreaming_electric_sheep.server.openapi.v3 import OpenAPIHandler
from dreaming_electric_sheep.server.openapi.ui import (
ScalarUIProvider,
SwaggerUIProvider,
ReDocUIProvider,
)
from openapidocs.v3 import Info
from msgspec import Struct
app = Application()
docs = OpenAPIHandler(
info=Info(title="Dreaming Electric Sheep API", version="1.0.0"),
ui_providers=[
ScalarUIProvider("/docs"), # Scalar UI (default) at /docs
SwaggerUIProvider("/swagger"), # Swagger UI at /swagger
ReDocUIProvider("/redoc"), # ReDoc at /redoc
],
)
docs.bind_app(app)
class Sheep(Struct):
id: int
name: str
voltage: float
@get("/api/sheep/:id")
def get_sheep(id: int) -> Sheep:
"""Retrieve an Electric Sheep by ID."""
return Sheep(id=id, name="Cloud Sheep", voltage=220.0)
⚡ Developer CLI (des)
The des CLI is the first-class toolchain for development, inspection, and operations:
des new demo -t api # Scaffold REST API project (Scalar UI default)
cd demo && des dev # Start development server with auto-reload (Granian RSGI)
des run app:app --workers 4 # Start production server (Granian RSGI)
des check # Validate routes, compiled binders, and configuration
des routes # Inspect compiled radix routing table
des why POST /api/items # Explain route match, binders, and pipeline
des doctor # Inspect C-core, intern tables, and runtime environment
🧱 Dependency Injection & Controllers
Dreaming Electric Sheep includes built-in dependency injection with pre-bound fast dispatching:
from des import Application
from dreaming_electric_sheep.server.controllers import Controller, get
class DatabaseService:
def get_stats(self) -> dict:
return {"active_connections": 42}
app = Application()
app.services.add_singleton(DatabaseService)
class StatusController(Controller):
@get("/api/status")
def get_status(self, db: DatabaseService):
return {"status": "ok", "db": db.get_stats()}
🏎️ Benchmarks & Framework Tax
Overhead measured against a shared in-memory fixture on localhost (median of 5 independent runs, 5s duration each, 50 concurrent keep-alive connections via oha, 1 worker process on CPython 3.14 / Linux x86_64).
Table A: Framework Tax vs. Raw Server Ceilings (msgspec Encoder)
Measures framework tax against raw server ceilings when all targets encode JSON per request using msgspec.json.encode and run with optimize_gc=False. The ~20% gap represents the necessary cost of route matching, request abstraction, and parameter binding over raw protocol sockets.
| Framework / Layer | Plaintext (req/s) | JSON (req/s) | Mem get (req/s) | Mem get ×20 (req/s) | HTML fortunes (req/s) | Mem update ×20 (req/s) | Server / Runtime |
|---|---|---|---|---|---|---|---|
| Granian (Raw RSGI) | 101,573 | 96,725 | 97,370 | 51,698 | 25,862 | 36,321 | Raw Granian RSGI (ceiling) |
| Granian (Raw ASGI) | 70,343 | 72,069 | 66,652 | 40,249 | 22,480 | 32,425 | Raw Granian ASGI (ceiling) |
| Dreaming Electric Sheep (RSGI) | 77,479 | 71,686 | 69,456 | 37,368 | 26,411 | 33,479 | Granian (RSGI, 1 worker) |
| Dreaming Electric Sheep (ASGI) | 73,348 | 66,781 | 64,345 | 28,635 | 20,869 | 25,841 | Granian (ASGI, 1 worker) |
| Uvicorn (Raw ASGI) | 45,141 | 44,846 | 39,480 | 27,776 | 18,014 | 23,548 | Uvicorn (Raw ASGI, 1 worker) |
Table B: Default Stack Comparison (Stock Helpers Out-of-the-Box)
Measures out-of-the-box performance using each framework's stock response and serialization helpers:
| Framework | Plaintext (req/s) | JSON (req/s) | Mem get (req/s) | Mem get ×20 (req/s) | HTML fortunes (req/s) | Mem update ×20 (req/s) | Server / Runtime |
|---|---|---|---|---|---|---|---|
| Dreaming Electric Sheep (RSGI) | 54,610 | 58,618 | 62,643 | 33,969 | 26,208 | 27,064 | Granian (RSGI, 1 worker) |
| Dreaming Electric Sheep (ASGI) | 53,654 | 56,337 | 56,363 | 31,566 | 23,949 | 28,435 | Granian (ASGI, 1 worker) |
| Emmett | 47,619 | 36,772 | 41,197 | 23,386 | 20,620 | 19,203 | Granian (RSGI/ASGI, 1 worker) |
| Sanic | 37,437 | 34,246 | 31,727 | 19,446 | 16,008 | 16,405 | Sanic (1 worker) |
| Litestar | 28,096 | 23,169 | 26,140 | 14,544 | 14,457 | 14,312 | Granian (ASGI, 1 worker) |
| Robyn | 22,839 | 23,090 | 21,441 | 9,783 | 11,640 | 13,420 | Robyn Rust (1 worker process) |
| Flask | 19,936 | 17,730 | 16,301 | 5,395 | 9,891 | 4,969 | Granian (WSGI, 1 worker) |
| Django | 16,498 | 11,314 | 12,482 | 5,690 | 10,493 | 5,407 | Granian (WSGI, 1 worker) |
| FastAPI | 15,421 | 16,053 | 13,353 | 5,719 | 10,739 | 5,746 | Granian (ASGI, 1 worker) |
Environment: x86_64 Linux, CPython 3.14 | Granian 2.8.2 | Uvicorn 0.34.2 |
oha 1.16.0. See perf/compare/ for harness scripts.
📕 License & Credits
Dreaming Electric Sheep is released under the MIT License. Derived from BlackSheep (Copyright (C) Roberto Prevato and contributors). See NOTICE for attribution.
made with by EduLoboM
Metadata
Release files for dreaming-electric-sheep 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dreaming_electric_sheep-1.1.2.tar.gz | 2.0 MB | Details |
Built distributions (wheels)
Total release size: 81.0 MB
Release files / dreaming_electric_sheep-1.1.2.tar.gz
| Download URL | dreaming_electric_sheep-1.1.2.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81bac2ad70dc48c58d2a0c58bde297b5d5e6da4ad93dda5c5cc90c4917837301
|
|
BLAKE2b-256 checksum How to use checksums |
8f272c8ea56b8081d9918b042bf4bb124f61ca7573dcfcebb18b3d35f7647d16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp314-cp314-win_arm64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp314-cp314-win_arm64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.14 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
6816018ed64564c3bf846ebc51eaf23e9eac26204f615dd30b44e3dce96bbac3
|
|
BLAKE2b-256 checksum How to use checksums |
280d921743f56c3e162bb8708294fc9a39295c1f8862db5f6e33d2425f740edd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp314-cp314-win_amd64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ec53ff2b4765e76e00625e01e2b3fb448cfd47517f867520816ac014def00d86
|
|
BLAKE2b-256 checksum How to use checksums |
ecf4a3a6a41c28d4519659a7fc2162e82f4ea9b1568ebd3b0c53e5699bdc7983
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp314-cp314-musllinux_1_2_x86_64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp314-cp314-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 7.6 MB |
| Tags | CPython 3.14 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
daa4bbf617800a8d622e2f845bc91fd572940a9153f0a25e71283e3d82b1105d
|
|
BLAKE2b-256 checksum How to use checksums |
7fda9258a59969487d7371d9a490f961f4037ec07eef58f69bbdd659e3af849c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp314-cp314-musllinux_1_2_aarch64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp314-cp314-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 7.6 MB |
| Tags | CPython 3.14 Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
ed16b04b1ac704f732c59a3996e59afc545690c3b69f644bbbbcfa711ee370fc
|
|
BLAKE2b-256 checksum How to use checksums |
f49cca33c062998bbbc7064e2952770ad97a1d4d55728fe80a1f562ea6897bd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 7.8 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
3e3741adecbdfb8e7da464d08687a8b4424f6afcfaa26867f6bce10c00d607c6
|
|
BLAKE2b-256 checksum How to use checksums |
f9e9b1ce5972c3f0e7a01fae858a6e3c456ad4effbe49cb776ed8ffc35c5ec08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 7.8 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
eab428c2655004ac80309c3edba63110ef2ccf9f8b9565191a684c8ff88780a1
|
|
BLAKE2b-256 checksum How to use checksums |
bf1bdc9115986f08d01a3b24d9e6eb2af62d7384dc1408bb1c6cd291b23bddea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp314-cp314-macosx_10_15_universal2.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp314-cp314-macosx_10_15_universal2.whl |
|---|---|
| Size | 3.5 MB |
| Tags | CPython 3.14 macOS 10.15+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
5642c2ea4c555e27c830c7fbb5a074d3373ca11dc020f8ae9b43876daded6f13
|
|
BLAKE2b-256 checksum How to use checksums |
ad72eb7b58aa99810179276f580cf16fd9f41cc067f69e7412d2eb4f5a165ed8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp313-cp313-win_arm64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp313-cp313-win_arm64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.13 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
4a3a493cfae36b6bd791f3d326b89f383668543b5a0cbe00d135f9b574045817
|
|
BLAKE2b-256 checksum How to use checksums |
f003e25767522533e4e082a6c08be7b1019ed4b788c95a2b2c594fa9298ec851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp313-cp313-win_amd64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
851f2432066fa8927bfe53ec7d015942360b1da6b16315f31b8c80ac163e3be5
|
|
BLAKE2b-256 checksum How to use checksums |
69efbdc51751ad59e9d5ca236c125be261ec1490a0b50b38330b9ac43ec57580
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 7.7 MB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
3abfc204fc8c797eca1e9b1b1a386d1b0d19d6ade343a78184cd57c9b134e8e4
|
|
BLAKE2b-256 checksum How to use checksums |
712efd246bb049f1f4447aa8a60092dcc579c07b33cc028e6d61ce9c19582f95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp313-cp313-musllinux_1_2_aarch64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp313-cp313-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 7.6 MB |
| Tags | CPython 3.13 Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
71f82246756bcf0d5a0432453e7ab503837039b7ba292e48e345e4c8575fa2be
|
|
BLAKE2b-256 checksum How to use checksums |
36a1b01fbf571318b8469a4a8a31869d50070f1021de32fa263cb44a7dbf2bb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 7.9 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
c572a5f340ffb8e20ef652a57dfc30a7db02adebdd3d9fbd80ff791718f78395
|
|
BLAKE2b-256 checksum How to use checksums |
1fb9319fafb4426e7052f6edbdc3dfc8ca509d4a8b30dc0f26a96c5bb3ad7ff7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 7.8 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
4028d9b7a80b1800529788311e2a61f02857c2e2c5ab0afafc1c4ce2cacbe368
|
|
BLAKE2b-256 checksum How to use checksums |
0e03cb79893b010c13b46712f31952ed5c746c9b467b60917df782fd515af845
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / dreaming_electric_sheep-1.1.2-cp313-cp313-macosx_10_13_universal2.whl
| Download URL | dreaming_electric_sheep-1.1.2-cp313-cp313-macosx_10_13_universal2.whl |
|---|---|
| Size | 3.5 MB |
| Tags | CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
a43b0dbf1ba4b60cf0eb4a2535dccc53db18c5e1ca7ebb7846282e186c040768
|
|
BLAKE2b-256 checksum How to use checksums |
b1650cab6b4d553d22a4d1dc52dbdff603906b4ef046d877ac8871cd86bf8a73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|