Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 1.04 KB

Lecture.md

File metadata and controls

37 lines (28 loc) · 1.04 KB

Dictish

Design Goals

  • Implement a dict-like object without relying on dict.
  • Implement enough of dict's behaviour to make it useful.
  • Avoid mutation.
  • Extend the functionality beyond what's available in dict in Python 3.8.
    • Supporting merging two dictish through or:ing them (d | other).
    • Supporting appending to a dictish by add:ing to it (d + key_value_pair).
    • Behaving like a function (callable).
    • Supporting subset and superset comparisons of two dictish.

Tutorial Steps

  1. Basic, empty dictish.
  2. Basic dictish with key-value pairs.
  3. Iterating over keys, values, and items.
  4. Supporting subscript (d["key"]).
  5. Supporting get (d.get("key")).
  6. Equality.
  7. Deduplicating key-value pairs.
  8. Supporting | and +.
  9. Representation (repr and str).

Going Further

  1. Hello doctests!
  2. Extracting a helper collection class.
  3. A bit of inspiration taken from Clojure.
  4. Subset and superset comparisons.

Stretch Goals

  1. A word on hashing.
  2. A word on Abstract Base Classes.