Python

Advanced

https://realpython.com/tutorials/advanced/

Memory profiles

https://github.com/bloomberg/memray

pypy

sudo add-apt-repository ppa:pypy/ppa
sudo apt update
sudo apt install -y pypy3 pypy3-venv

Avoid calling functions in hot loops (for performance)

ORM

  • Pony

  • Tortoise (async)

Core Python

Dataclasses

from dataclassses import dataclass, field

@dataclass(frozen=True, order=True)
class Comment:
    id: int
    text: str
    replies: list[int] = field(default_factory=list)

Inspect

import inspect

print(inspect.getmembers(THE_CLASS, inspect.isfunction))

dis

Last updated