~/talk

Whose Method Is It Anyway?

Talkat Conf42 Python 2021 · on Thursday, 2021-05-27· [python, software-architecture]
slides:none on file

Explains how Python uses the C3 MRO to produce a deterministic superclass linearization, illustrated with pizza/sandwich/calzone diamonds and how lookup walks that linearization left-to-right until it finds a method. Shows the MRO failing with TypeError cannot create a consistent method resolution for conflicting orders and two practical fixes: swap inheritance order or explicitly invoke the desired implementation with Class.method(self, ...). Ends with a mixin example (barista vs short_order_cook) that demonstrates these fixes.

AI-written summary · about

  1. 0:00Multiple inheritance fears
  2. 1:41Python’s multiple inheritance
  3. 2:45C3 method resolution order
  4. 6:16Simple inheritance examples
  5. 9:32Method resolution in complex inheritance
  6. 12:23Diamond inheritance conflicts
  7. 14:08Advanced patterns and advice
  8. 15:33Mixins and multiple inheritance
  9. 19:24Live coding mixins
  10. 39:21Mixins pitfalls
  11. 40:01Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.