Skip to content

Instantly share code, notes, and snippets.

View x42005e1f's full-sized avatar

Ilya Egorov x42005e1f

View GitHub Profile
@x42005e1f
x42005e1f / init.py
Last active April 4, 2025 12:25
__all__-based dynamic exports
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 Ilya Egorov <[email protected]>
# SPDX-License-Identifier: 0BSD
__all__ = (
'init',
)
from sys import modules
@x42005e1f
x42005e1f / aiologic_fibonacci_bench.py
Last active April 4, 2025 12:27
One of aiologic's most impressive benchmarks
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 Ilya Egorov <[email protected]>
# SPDX-License-Identifier: 0BSD
import sys
import time
import threading
from concurrent.futures import ThreadPoolExecutor, wait
@x42005e1f
x42005e1f / rps.py
Last active November 10, 2025 01:36
A rate limiter (async-aware only)
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2022 Ilya Egorov <[email protected]>
# SPDX-License-Identifier: 0BSD
__all__ = (
"RPSLock",
)
from functools import wraps
@x42005e1f
x42005e1f / glock.py
Last active November 6, 2025 18:29
A group-level lock (async-aware & thread-aware)
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2025 Ilya Egorov <[email protected]>
# SPDX-License-Identifier: ISC
from __future__ import annotations
from collections import OrderedDict
from typing import TYPE_CHECKING
@x42005e1f
x42005e1f / patcher.py
Last active August 23, 2025 21:32
Some patches for thread-safety (threading & eventlet)
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 Ilya Egorov <[email protected]>
# SPDX-License-Identifier: ISC
# mypy: disable-error-code="attr-defined, import-untyped, no-untyped-def"
# pyright: reportAttributeAccessIssue=false, reportOptionalMemberAccess=false
from __future__ import annotations