Skip to content

Instantly share code, notes, and snippets.

@Mark1002
Mark1002 / __init__.py
Created October 23, 2020 14:10
python auto load sub module class.
from inspect import isclass
from pkgutil import iter_modules
from pathlib import Path
from importlib import import_module
REF = {}
# iterate through the modules in the current package
package_dir = str(Path(__file__).resolve().parent)
@Mark1002
Mark1002 / bench_asyncio.py
Last active September 10, 2023 12:59
python and go concurrency comparison
import asyncio
import time
import random
async def task(n: int):
await asyncio.sleep(random.randint(1, 3))
print(f"task{n} finish")