Switched JSON serialization to orjson for faster encoding and decoding.
CI / Formatting (push) Failing after 4s
CI / Linting (push) Successful in 4s
CI / Tests (Python 3.12) (push) Successful in 12s
CI / Tests (Python 3.13) (push) Successful in 12s
CI / Tests (Python 3.14) (push) Successful in 10s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 5s
Audit / Dependencies (push) Successful in 7s

This commit is contained in:
2026-04-05 10:19:07 -04:00
parent 2d2214c671
commit 100cbc3bef
8 changed files with 76 additions and 14 deletions
@@ -23,13 +23,13 @@ from __future__ import annotations
import asyncio
import contextlib
import json
import secrets
from html.parser import HTMLParser
from pathlib import Path
from typing import TYPE_CHECKING
import emoji
import orjson
from aiohttp import web
if TYPE_CHECKING:
@@ -203,7 +203,7 @@ async def _broadcast(
:param events: The event data dicts to broadcast.
:param logger: Logger instance from the module context.
"""
payload = "".join(f"data: {json.dumps(event)}\n\n" for event in events).encode()
payload = b"".join(b"data: " + orjson.dumps(event) + b"\n\n" for event in events)
snapshot = list(clients)
results = await asyncio.gather(
*(client.write(payload) for client in snapshot),