Skip to content

vivekkeshore/python_asia_2026

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Under the Hood: Hacking Python Data Types for Fun and Power

Talk presented at Python Asia (PyCon APAC) 2026.

About

All of us have wondered sometime, what really happens when a list is created, or compare dictionaries, or use objects as set keys in Python? This talk explores the inner workings of Python's core data types - lists, tuples, dicts, sets, and more - from the perspective of internal implementation, memory, mutability, method resolution and more.

Along the way, we look at practical examples of customizing these behaviors using special methods. Let's make an immutable list or a mutable tuple - we explore what's possible, what's dangerous, and what's just plain fun.

Slides

https://my.visme.co/view/nmngo6rz-python-asia-2026

Demos

File Topic
demo1.py List basics - how len() and + map to dunder methods
demo2.py Dict ordering - dict vs OrderedDict in modern Python
demo3.py Hashable list - using a list as a dictionary key
demo4.py Indexed set - adding __getitem__ to a set
demo5.py Indexed set with slice support
demo6.py TimeSeries - date-based __getitem__ indexing
demo7.py OrderedSet - a set that preserves insertion order
demo8.py Breaking frozen dataclass via object.__setattr__
demo9.py Mutable tuple - modifying a tuple in memory with ctypes
demo10.py Generators and two-way communication with send()
demo11.py Generator-based coroutines - producer-consumer pattern
demo12.py Rolling average using generator send()

Run any demo:

python demo1.py

Requirements

  • Python 3.10+
  • No external dependencies (only stdlib: ctypes, collections, dataclasses, hashlib, datetime)

Note: demo9.py (mutable tuple) is CPython-specific and handles the struct layout differences between Python <= 3.13 and Python 3.14+.

Talk Outline (30 minutes)

  1. Introduction (3 min) - Why look under the hood?
  2. Python Data Model in Action (10 min) - Dunder methods, hash contract, mutability
  3. The Hacks & Demos (14 min) - Hashable list, mutable tuple, indexed set, ordered set, date-indexed TimeSeries, frozen dataclass bypass, generator coroutines
  4. The Good, the Bad, and the Dangerous (2 min) - When these hacks help vs when they break things
  5. Wrap-up + Q&A (1 min)

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages