PyTexas 2013

__instancecheck__ and user-defined type systems

James Powell is a Python programmer residing in New York City. He is the co-organiser of the NYC Python meetup (nycpython.com) and has spoken at PyData SV, PyData NYC, PyTexas, PyArkansas, PyGotham, and at the NYC Python meetup. He also authors a blog on Python topics at dontusethiscode.com

instancecheck and subclasscheck are part of the fundamental protocols supported by objects in Python, and they are used in the standard library to support type checking via interfaces (e.g., isinstance(x, collections.Iterable) instead of type(x) is list)
This talk discusses how they work, from an end-user perspective and from the perspective of a CPython developer, and what these can be used for (e.g., modelling problems with user-defined, custom type systems.) This talk will also discuss real-world problems in a giant, multi-million line Python system that the presenter has seen and resolved using knowledge of these constructs.

Status: Accepted