Skip to content

Instantly share code, notes, and snippets.

@Mastermind-U
Mastermind-U / BST.py
Created November 13, 2023 18:57
Binary search tree, no recursion.
"""Python3 function to search a given key in a given BST."""
class Node:
left: 'Node' = None
right: 'Node' = None
def __init__(self, key):
self.key = key
@Mastermind-U
Mastermind-U / circular_list.py
Last active November 12, 2023 20:48
Circular linked list python implementation.
"""Circular linked list python implementation."""
from typing import Generator, Generic, Iterable, Protocol, Sized, TypeVar
class EqProtocol(Protocol):
"""Protocol with eq method."""
def __eq__(self, __value: object) -> bool: ... # noqa
@Mastermind-U
Mastermind-U / asyncio_background_benchmark.py
Last active November 12, 2023 16:29
Aysyncio memory benchmark for ensure_future vs create_task background coroutines
import asyncio
from memory_profiler import profile
SIZE = 100000
@profile
async def ensure_test():
loop = asyncio.get_running_loop()
@Mastermind-U
Mastermind-U / asyncgens.py
Last active September 13, 2023 17:09
Example of asynchronous python code with deque and generators
from collections import deque
def arange(stop):
for i in range(1, stop + 1, 1):
print(i, "/", stop)
yield
else:
return i
@Mastermind-U
Mastermind-U / .gitlab-ci.yml
Last active July 3, 2022 17:45
Django gitlab.ci
image: docker:latest
services:
- docker:dind
stages:
- build
- test
- deploy
image: docker:latest
services:
- docker:dind
stages:
- build
- test
- deploy