Python Type System: Building an effective mental model

Madhukar Mishra (~madhukar93)




Do you use isinstance() frequently and know there is a better way, but you just don’t know how? Have you been bitten from using mutable arguments to functions?

Python has an interesting data model as a dynamic language. This model shapes the programs you write and a good understanding of this goes a long way in writing effective code. This talk covers the various approaches you could take to handle the behaviour of your objects from duck-typing to the new dataclasses introduced in Python 3.7. We will also take a deep dive into the Python data model itself and see how we can leverage it to give intuitive APIs to our libraries. All the benefits of having a thought out data model apply. Your code can be cleaner and easier to test.

"Bad programmers worry about the code. Good programmers worry about data structures and their relationships." - Linus Torvalds

"Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious." - Fred Brooks

  • Python is strongly typed (2 min, total: 2min)
  • Python is dynamically typed (2 min, total: 4 min)
  • Now I don't know what object I have ! (3 min, total: 7 min)
  • Duck typing and variable naming
  • Modelling data in Python (12 min, total: 19 min)
  • class vs dicts: Which one do you need
  • Metaclasses: The case of the Django ORM
  • Dataclasses: The syntax sugar we always wanted
  • Gradual/optional typing in Python (5 min, total: 24 min)
  • static type checking and type safety


Familiarity with object oriented Python

Speaker Info:

I am a full stack dev at Grofers where Python is our first choice for everything from backend services to infrastructure orchestration. I have worked on a wide range of solutions using Python, among them are APIs that power our consumer ecosystem at scale, inventory/content management systems, and other high throughput ETL services in Python.

Speaker Links:



Id: 965
Section: Core python and Standard library
Type: Talks
Target Audience: Intermediate
Last Updated: