Python

Anti-Patterns

Background tasks

Dataclasses

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

ProfilerWhatGranularityHow
timeitrun timesnippet-level
cProfilerun timemethod-leveldeterministic
statprof.pyrun timemethod-levelstatictical
line_profilerrun timeline-leveldeterministic
memory_profilermemoryline-level+- deterministic
pymplermemorymethod-leveldeterministic

Fonte: https://www.youtube.com/watch?v=DUCMjsrYSrQ