Python
Anti-Patterns
Background tasks
Dataclasses
- attrs vs pydantic: Why I use attrs instead of pydantic
f-string
debugging
user = "eric_idle"
f"{user=}"
# "user='eric_idle'"
f"{user = }"
# "user = 'eric_idle'"
padding
val = "test"
f"{val:>10}"
# ' test'
f"{val:<10}"
# 'test '
f"{val:_<10}"
# 'test______'
f"{val:^10}"
# ' test '
Fonte: https://fstring.help/
Profiling
Profiler | What | Granularity | How |
---|---|---|---|
timeit | run time | snippet-level | |
cProfile | run time | method-level | deterministic |
statprof.py | run time | method-level | statictical |
line_profiler | run time | line-level | deterministic |
memory_profiler | memory | line-level | +- deterministic |
pympler | memory | method-level | deterministic |