Contribute Media
A thank you to everyone who makes this possible: Read More

Slot or not: higher performance custom objects in pure Python


__slots__ are versatile for certain kinds of uses and users, if you know how they work.

At first glance, they seem like a free lunch, with improvements in both time and space. At second glance, they seem to have so many caveats to make them not worth using.

This talk is a deep dive into how __slots__ work, how to wring every benefit out, as well as the actual caveats and alternatives, with recommendations for writers of core libraries as well as end users.


Improve this page