The 8 things that happen at the "." between an object and the attribute

1:30pm - 1:55pm on Saturday, October 7 in PennTop South

Andy Fundinger

Audience Level:
Intermediate
Watch:
https://youtu.be/Bg_cEIkOS9g

Overview

We rarely think about the dot “.” between our objects and their fields, but there are quite a lot of things that happen every time we use one in Python. This talk will include the commonly known functions, (dict, getattr, etc), but especially focus on the Descriptor Protocol.

Description

We rarely think about the dot “.” between our objects and their fields, but there are quite a lot of things that happen every time we use one in Python. This talk will explore the details of what happens, how the descriptor protocol works, and how it can be used to alter the Python object model.

Actions to be explored:

  1. The instance dict is checked.
  2. The class dict is checked.
  3. The base classes dicts are checked.
  4. getattr runs.
  5. getattribute runs.
  6. The get method on the object in the class dict is called.
  7. The object in the class dict is checked for a set method.
  8. raise AttributeError

Most of the talk will focus on 6 & 7 to explain the Descriptor protocol. Examples will include altering method binding and property behaviors, as well as supporting method implementation reuse via Descriptors.

Want to edit this page?