Skip to content

Instantly share code, notes, and snippets.

View Vizonex's full-sized avatar

Vizonex Vizonex

View GitHub Profile
@Vizonex
Vizonex / http2_writer.py
Last active September 12, 2025 02:39
an http/2 writer concept for aiohttp
# Currently this is a concept as the plan for aiohttp's http2 support
# is still under some debate:
# Author: Vizonex
# Filename (If added): "aiohttp/http2_writer.py"
"""Http related parsers and protocol."""
import asyncio
import sys
from typing import ( # noqa
@Vizonex
Vizonex / http2_parser.py
Created September 13, 2025 23:56
Aiohttp http/2 parser concept inspired by my previous work with http2_writer.py for parsing frames from incoming servers and clients
# Currently this is a concept as the plan for aiohttp's http2 support
# is still under some debate:
# Author: Vizonex
# Filename (If added): "aiohttp/http2_parser.py"
from contextlib import suppress
from enum import IntEnum
from typing import (
Any,
ClassVar,
@Vizonex
Vizonex / api.c
Created September 17, 2025 22:18
Inspired by llhttp this is a http2 frame parser concept for upcoming C Library on github for use with aiohttp and other libraries
#include "api.h"
#include <stdio.h>
// Don't want to override llhttp's work now do we?
#define H2_CALLBACK_MAYBE(PARSER, NAME) \
do { \
const llh2_settings_t *settings; \
settings = (const llh2_settings_t *)(PARSER)->settings; \
if (settings == NULL || settings->NAME == NULL) \
{ \
@Vizonex
Vizonex / _helpers_c.c
Created October 12, 2025 19:44
propcache under_cached_property CPython Concept for moving propcache over to CPython instead of Cython for higher control over Refs and optimizing performance, this is currently incomplete hence me uploading it here.
/* This was a backup plan I had in mind if cimporting propcache from cython gets rejected
My main reason behind trying to force it in CPython or Cython is actually to come up with a new library
that deprecates property types (including cached properties) without needing to write
@deprecated(reason="blah blah blah")
@property
It is easier said as
@deprecated_property(reason="blah blah blah")
@Vizonex
Vizonex / CWriter.h
Last active October 19, 2025 19:41
concet for a new writer for aiohttp based written in CPython based off the current aiohttp _http_writer written in cython but with a few more apis for http/2 http/3 frame packing
/* This CPython Writer is a mirror of the aiohttp & Yarl source code for implementing
a fast and easy to use writer that could be implemented & Used in Cython and
CPython projects. This was an idea for the transition of the current _http_writer
cython module in aiohttp on over to C When or if we decide to go down that route with
header serlization with Http/1.1 ,
This also has new tools that could be used for http/2 Frame writing
so this library also implements tools that the struct module would use but for writing
in special bytes.
@Vizonex
Vizonex / aiosched.py
Last active October 29, 2025 15:59
python's standard scheduler made for asyncio with a couple of upgrades. IF anyone wants this I'll make it into a pypi package and I'll go and add some pytests.
"""A Small and compact scheduler built off asyncio and reedited around python-std sched"""
from __future__ import annotations
import asyncio
import heapq
import inspect
import types
from itertools import count
from typing import (
@Vizonex
Vizonex / anyioshed.py
Created October 31, 2025 20:01
Mainly used so I can demonstrate something I wanted implemented in apsheduler before learning it existed. This code runs correctly and I have a quick and dirty example of the way it is used.
"""A Small and compact scheduler built off anyio and reedited around python-std shed"""
from __future__ import annotations
import inspect
import sys
from collections import deque
from datetime import datetime, timedelta
from itertools import count
from typing import (
@Vizonex
Vizonex / fix_yaml.py
Created November 11, 2025 23:38
Fixer for pre-commit under the circumstances that were on windows and pre-commit-yaml doesn't decide to play nicely with us.
# Small mini fixer for pre-commit yaml to play nicely with windows since windows has it's own quirks unlike linux.
# This repairs and fixes the probelm.
import sys
import pathlib
if __name__ == "__main__":
if ("--help" in sys.argv) or ("-h" in sys.argv):
print(" fix_yaml.py <FILE>\n")
print(" FILE A yaml file that needs fixing")
print(" --help, -h Prints help and exits")
@Vizonex
Vizonex / deprecated_subclass.py
Last active December 7, 2025 15:51
This was a concept for a new library to supply a deprecation warning that subclassing an object is deprecated this is good for warning users not to subclass the type of object your planning to disallow subclassing for. Code originates from my cyares project but I plan to seperate it if someone wants it as it's own pypi package.
"""A External Module for the deprecation of subclassing a class
this will be a seperate library soon if demand is seen for it."""
import functools
import warnings
from collections.abc import Sequence
from types import MethodType
from typing import TypeVar
# Modeled after deprecated-params but for the deprecation of subclassing
@Vizonex
Vizonex / _http_writer.pyx
Created February 9, 2026 19:47
MultiDict Optimization workaround that focuses on making it possible to optimize iterations without hindering the performance of other types of objects or the multidict python backup This idea is still under concept so just a warning!
# here's how we could use our custom module we made to eliminate some slowness with other things.
# example show is aiohttp/_http_writer.pyx with a few upgrades but also our own module being injected on in.
from cpython.bytes cimport PyBytes_FromStringAndSize
from cpython.exc cimport PyErr_NoMemory, PyErr_SetString, PyErr_SetObject
from cpython.mem cimport PyMem_Free, PyMem_Malloc, PyMem_Realloc
from cpython.object cimport PyObject_Str
from libc.stdint cimport uint8_t, uint64_t
from libc.string cimport memcpy