Description
Anjana Vakil - Using and abusing Python’s double-underscore methods and attributes [EuroPython 2016] [21 July 2016] [Bilbao, Euskadi, Spain] (https://ep2016.europython.eu//conference/talks/using-and-abusing-pythons-double-underscore-methods-and-attributes)
Python’s double-underscore ('__') methods and attributes go by many names, including “special”, “dunder”, and “magic”. You already use some, like __init__, but there are many more!
In this talk, we’ll see how dunders can be useful, silly, dangerous, and fun! We’ll trick Python’s arithmetic and comparison operators. We’ll make objects behave like dictionaries and containers. We’ll reduce an object’s memory usage, and speed up membership tests. We’ll even try some naughty function hacks!
The curious Python methods and attributes surrounded by double underscores ('__') go by many names, including “special”, “dunder”, and “magic”. You probably use some of them, like __init__, every day. But that’s just the tip of the iceberg!
In this talk, we’ll explore the weird and wonderful world of the double-underscore, and find out how dunders can be useful, silly, dangerous, and just fun! We’ll play pranks on Python’s builtin operators for arithmetic and comparison. We’ll make arbitrary objects behave like dictionaries and containers. We’ll reduce an object’s memory usage, and speed up tests for membership. We’ll even try some naughty function hacks that we should never use in real life!
You'll get the most out of this talk if you're already comfortable writing object-oriented Python code. If you already use special dunder magic in your own code, that's excellent! You’ll have a chance to share your tips & tricks with the rest of the audience at the end of the talk.
Talk repo: https://github.com/vakila/dunders