impedimenta

Dat Python, dataclass

Dataclasses are cool, but what’s cooler is using immutable structures as your default parameters. Do it like so:

import dataclasses as dc

@dc.dataclass(frozen=True)
class MinCut:
  T:set = dc.field(
    default_factory=set, compare=False)
  F:set = dc.field(
    default_factory=set, compare=False)

Also check out some more magic in the official docs. Of note: representation, __post_init__ hooks, dataclasses.replace fields.

See also:Joblib for memoization · GitHub actions 101 · Python servers and WSGI · Building Athens Research (Clojure/JS)