PythonAsia 2026

PythonAsia 2026

Let's implement useless Python objects
2026-03-21 , Teresa Yuchengco Auditorium (Main Hall)

Let's implement objects that are useless for anything.
For example, an object whose length returned by the len() function is different every time, or an object that returns a bullshit result when you check if a value exists with the in operator.
And through the implementation, you will get a better understanding of Python data types.


The Python objects implemented in this presentation are not useful at all.
However, implementing completely useless objects will give you a better understanding of Python data types.
You will then be able to implement useful objects.

There are two topics covered in this presentation.

The first is understanding what happens behind the scenes of the len() function, the in operator, and the for statement.
For example, if you pass an object obj to the len() function, the result of len(obj) will be obj.__len__().
In other words, if you screw up the implementation of obj.__len__(), the result of len(obj) will also be screwed up.
You will understand what Python does behind the scenes, why you can create useless objects, and how to implement objects that behave correctly.

Second, you will understand how to use the abstract base classes in collections.abc.
Python's built-in containers include lists, tuples, dictionaries, and sets.
And the built-in containers, simply put, consist of the abstract base classes Sized, Container and Iterable in collections.abc.
If you try to implement a useless object and implement it in an absurd way, you will not be able to use it properly.
Using the abstract base class, you can create useless objects whose behaviour is absurd, but which also work with existing Python objects.
Through this experience, you will learn how to use abstract base classes and how to create your own containers correctly.

The basic agenda is as follows

  • Preliminaries: let's create a totally useless object.
  • Basics: start with Sized, Container and Iterable.
  • ElasticSized: an object that changes the return value of the len() function each time it is executed.
  • ForgottenContainer: an object where the result of the in operator changes each time it is executed.
  • ShuffledIterable: An object whose for statement changes the result each time it is executed.
  • Applications: Uncontrolled containers.
  • UncontrolledSequence: An uncontrolled sequence.
  • MisprintedDictionary: A misprinted dictionary.
  • CrowdSet: A crowd set

Category: Core Python/Advanced Language Features Audience Level: Intermediate

A software engineer based in Japan.
Holds a master's degree in engineering from the University of Electro-Communications.
Currently works as a software engineer at Tokyo Gas Co., Ltd. while also playing tuba in the Tokyo Gas Wind Orchestra.