Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 1.1.1 instead.
Reason given by maintainers: Missing wheels for 3.14

Build pypi versions license

Electric Screaming Don Quixote EGO

Dreaming Electric Sheep

"The cloud has a head and two pairs of legs. It resembles a sheep."

Dreaming Electric Sheep is an ultra-high-performance, bare-metal asynchronous ASGI web framework for modern CPython (3.13–3.14+). Born as an aggressively optimized evolution of BlackSheep, it discards legacy runtime compromises (such as PyPy compatibility shims) to squeeze maximum throughput, microsecond-level latency, and direct C/C++/CUDA interoperability from standard CPython.


🔮 Key Highlights & Low-Level Architectural Features

1. 👾 PEP 590 Vectorcall Direct C-API Dispatch

All handler, middleware, and route dispatching bypasses Python *args tuple and **kwargs dict allocations. Handlers are invoked using PyObject_Vectorcall passing contiguous pointer arrays directly in CPU registers.

2. ⚓ Pure cdef class Extension Types (Zero __dict__ Overhead)

Request, Response, RouteMatch, Header, and Scope are pure Cython extension classes. All fields reside at fixed C-level struct offsets (pointer offset), eliminating dictionary lookups in the hot path.

3. 🌊 C-Level Object Freelists & Fast Pools

Request and Response instances are managed through dedicated C freelists (acquire_request, release_request, acquire_response, release_response), recycling objects across HTTP lifecycles and reducing Python heap pressure to near zero.

4. 🚄 SIMD Vectorization (AVX2 / SSE4.2 / ARM NEON / SWAR)

Custom C SIMD kernels accelerate:

  • CRLF and header boundary scanning (\r\n\r\n).
  • URL path separator tokenization (/).
  • ASCII header validation with fallback SWAR (SIMD Within A Register).

5. 🧊 In-Memory Request Scratchpad Arenas

Per-request linear arenas (scratchpad.h/.c) allow $\mathcal{O}(1)$ allocation and instant bulk resets without invoking malloc() or free() during request lifecycle processing.

6. 💎 Zero-Copy ASGI Ingestion

Direct bytes-like memoryview and buffer passing from server transport layers (Granian, Uvicorn) directly into msgspec decoders without intermediate string copies or heap duplications.

7. 🔋 Pre-Compiled Type Decoders & Fast DI Bindings

Endpoint payload decoders (msgspec.json.Decoder(type=...)) and controller activation paths are compiled ahead-of-time during application startup, eradicating runtime reflection.


🐍 CPython & C / C++ / CUDA Native Interoperability

[!IMPORTANT] Why CPython exclusively? Dreaming Electric Sheep purposefully removes PyPy and legacy Python support to target modern CPython C-APIs (3.13, 3.14+). If your workloads utilize:

  • C / C++ Native Extensions (e.g., custom Cython, pybind11, nanobind)
  • CUDA / TensorRT / PyTorch / ONNX Runtime for high-throughput AI/ML serving
  • SIMD hardware intrinsics (AVX2, AVX-512, NEON)

CPython provides the tightest possible low-overhead binding without JIT tracing overhead or foreign function interface (FFI) penalties.


⭐ Installation

pip install dreaming-electric-sheep

For maximum throughput and SIMD speed, install with httptools and uvloop:

pip install dreaming-electric-sheep httptools uvloop uvicorn granian msgspec

⚡ Quick Start & msgspec Integration

Dreaming Electric Sheep provides first-class, zero-overhead support for msgspec.Struct, dataclasses, and pydantic models with startup-cached pre-compiled decoders.

from dreaming_electric_sheep 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")
async def hello():
    return {"message": "Do electric sheep dream of high throughput?"}

@post("/api/items")
async def create_item(data: CreateItemInput):
    # Bound automatically with zero-copy buffer ingestion
    return {"status": "created", "item": data}

📙 OpenAPI 3.0, Swagger UI, Scalar & ReDoc

Dreaming Electric Sheep automatically generates OpenAPI 3.0 documentation from type annotations (msgspec.Struct, dataclasses, Pydantic, Python typing) and docstrings. It includes built-in support for Swagger UI, Scalar, and ReDoc.

from dreaming_electric_sheep import Application, get, post
from dreaming_electric_sheep.server.openapi.v3 import OpenAPIHandler
from dreaming_electric_sheep.server.openapi.ui import (
    SwaggerUIProvider,
    ScalarUIProvider,
    ReDocUIProvider,
)
from openapidocs.v3 import Info
from msgspec import Struct

app = Application()

# Configure OpenAPI with interactive documentation UIs
docs = OpenAPIHandler(
    info=Info(title="Dreaming Electric Sheep API", version="1.0.0"),
    ui_providers=[
        SwaggerUIProvider("/docs"),    # Interactive Swagger UI at /docs
        ScalarUIProvider("/scalar"),   # Modern Scalar UI at /scalar
        ReDocUIProvider("/redoc"),     # ReDoc at /redoc
    ],
)
docs.bind_app(app)

class Sheep(Struct):
    id: int
    name: str
    voltage: float

@get("/api/sheep/:id")
async def get_sheep(id: int) -> Sheep:
    """
    Retrieve an Electric Sheep by ID.
    """
    return Sheep(id=id, name="Cloud Sheep", voltage=220.0)

Now navigate in your browser:

  • Swagger UI: http://localhost:8000/docs
  • Scalar UI: http://localhost:8000/scalar
  • ReDoc: http://localhost:8000/redoc
  • Raw OpenAPI JSON Spec: http://localhost:8000/openapi.json

🔥 High-Speed Serialization: JSON & MessagePack

Take full advantage of pre-compiled type decoders and multiple wire formats:

from dreaming_electric_sheep import Application, FromJSON, FromMsgPack, FromQuery, post
from msgspec import Struct

class SensorPayload(Struct):
    device_id: str
    readings: list[float]

app = Application()

# JSON payload with precompiled type decoder
@post("/api/sensors/json")
async def ingest_json(data: FromJSON[SensorPayload]):
    return {"received_readings": len(data.value.readings)}

# Binary MessagePack payload (ultra-fast binary format)
@post("/api/sensors/msgpack")
async def ingest_msgpack(data: FromMsgPack[SensorPayload]):
    return {"received_readings": len(data.value.readings)}

🚀 Running the Application (CLI & ASGI Servers)

Dreaming Electric Sheep is a standard ASGI 3 application compatible with all ASGI servers.

1. Granian (Recommended for Extreme Throughput)

Granian is a high-performance Rust-based HTTP server.

# Production: Multi-threaded & Multi-worker
granian --interface asgi app:app --port 8000 --workers 4 --threads 2

# Development: Auto-reload
granian --interface asgi app:app --port 8000 --reload

2. Uvicorn (with uvloop & httptools)

Uvicorn provides a battle-tested Python/C networking stack.

# Production: uvloop + httptools
uvicorn app:app --port 8000 --loop uvloop --http httptools --workers 4

# Development: Auto-reload
uvicorn app:app --port 8000 --reload

🎯 Controllers & Dependency Injection

Dreaming Electric Sheep includes built-in dependency injection with pre-bound fast dispatching:

from dreaming_electric_sheep import Application
from dreaming_electric_sheep.server.controllers import Controller, get, post

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()}

app.controllers.register(StatusController)

made with love.png by EduLoboM

Download files

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

Source Distribution

dreaming_electric_sheep-2.6.3.tar.gz (346.8 kB view details)

Uploaded Source

Built Distributions

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

dreaming_electric_sheep-2.6.3-cp314-cp314-macosx_10_15_universal2.whl (3.1 MB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

dreaming_electric_sheep-2.6.3-cp313-cp313-win_arm64.whl (2.1 MB view details)

Uploaded CPython 3.13Windows ARM64

dreaming_electric_sheep-2.6.3-cp313-cp313-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.13Windows x86-64

dreaming_electric_sheep-2.6.3-cp313-cp313-musllinux_1_2_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

dreaming_electric_sheep-2.6.3-cp313-cp313-musllinux_1_2_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

dreaming_electric_sheep-2.6.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

dreaming_electric_sheep-2.6.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

dreaming_electric_sheep-2.6.3-cp313-cp313-macosx_10_13_universal2.whl (3.1 MB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

File details

Details for the file dreaming_electric_sheep-2.6.3.tar.gz.

File metadata

  • Download URL: dreaming_electric_sheep-2.6.3.tar.gz
  • Upload date:
  • Size: 346.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.15

File hashes

Hashes for dreaming_electric_sheep-2.6.3.tar.gz
Algorithm Hash digest
SHA256 6d859a03c2a475171664fbdc0e83499079c739d9346504e07861e238c453bb95
MD5 16cfe694c49988fd62ee7515501ab92d
BLAKE2b-256 173b7d47072d6371263d2a680e6ef8fdcaad6f8b902c6ff7f51c8ac7b9b93646

See more details on using hashes here.

File details

Details for the file dreaming_electric_sheep-2.6.3-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for dreaming_electric_sheep-2.6.3-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 d488dbc5c0eca8a4495b0ca891cf10574d131782c9d632d243a9bb4b650be410
MD5 fbe9c40b69c21cc631ebaae2cec96f41
BLAKE2b-256 815510bc21279f16a594acd23d16e234dee34334aab26673faf3f6ad5c7d0552

See more details on using hashes here.

File details

Details for the file dreaming_electric_sheep-2.6.3-cp313-cp313-win_arm64.whl.

File metadata

File hashes

Hashes for dreaming_electric_sheep-2.6.3-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 ae586d811d025128fb8887783f09b809d01bbb78e0690401cc14d53fd2942a01
MD5 3297b279693058a4b3750ffe85389b7e
BLAKE2b-256 c9a6f72452b0f6017eea29847aa6c9338f6eb5c8e72c65807b01fb1e73cc363d

See more details on using hashes here.

File details

Details for the file dreaming_electric_sheep-2.6.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for dreaming_electric_sheep-2.6.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4aa7c68e50c463aac4584a068c7d80acaaa70a9d3f38541663791c02bf4a3cb2
MD5 3b2f57d78b7789657b5d48644833ec49
BLAKE2b-256 807860967ea79de48b73a8ddc66ae31e21b26f43f4677d1ee519ad1b98918d89

See more details on using hashes here.

File details

Details for the file dreaming_electric_sheep-2.6.3-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for dreaming_electric_sheep-2.6.3-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c6b4cf2445c53160a9004c809fb36a93b70e12e0b50e4b49b129edbeb4ecdae9
MD5 4427fdce9c28fcc21d2bbc215145c1c4
BLAKE2b-256 537e4365739f7cc1091d2cd7360cf91e5dd7594d52c48866f415c494eefc749a

See more details on using hashes here.

File details

Details for the file dreaming_electric_sheep-2.6.3-cp313-cp313-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for dreaming_electric_sheep-2.6.3-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6f9b0a099a03f4802dc60f9ba3b203a50cc2e6cfc0ff8d5a3501ea1bce5193af
MD5 27001f6dbabe1592bec401685c0f437e
BLAKE2b-256 354dabe36a18f2be8d51db95d207f3bbef8cd9dcd7d7d34a74a2bef60ee5c6e8

See more details on using hashes here.

File details

Details for the file dreaming_electric_sheep-2.6.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dreaming_electric_sheep-2.6.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0696dd5eac249a3f82e5dc8421b08e2959189076be046bf4bac059268ee718f9
MD5 525c8b09498f84f78eb137a315557cca
BLAKE2b-256 4dbd37c9c50c31158cb50606b4914a17dd8b6330089447aeba979c1f6a7d7c83

See more details on using hashes here.

File details

Details for the file dreaming_electric_sheep-2.6.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for dreaming_electric_sheep-2.6.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c9bb1972388610de95e7eeedf47004a282f0e4f43b9f4963778f65079a7dd7fc
MD5 86bd429a2275388f8503ee2793c703b9
BLAKE2b-256 a79a9c3d02b552ee368dba60ea741b98830e24c2cb3c6d69b078a65d022e3e6c

See more details on using hashes here.

File details

Details for the file dreaming_electric_sheep-2.6.3-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for dreaming_electric_sheep-2.6.3-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 7390a946c451c5c5145c24183bf61bb54a629501155a5e0e1bb5cf447c145748
MD5 40cdb8aafe19cf4d6b7df60ac48899e5
BLAKE2b-256 b27662378ff686c0d3af4455b6286195fce03a8243f87062d6fa34aa5721359a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.6.3 This release

9 files

1.1.1

15 files

1.1.0

15 files

1.0.0

15 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