2 ms·
> For example, if we define the __add__() special method on an existing class, it will set the nb_add slot of the class to the default implementation that calls
by pansa2 6y ago
> For example, if we define the __add__() special method on an existing class, it will set the nb_add slot of the class to the default implementation that calls the method.
See also this post from 2014, which argues that this is a bad design. It claims that Python would be both simpler and faster if it looked up special methods like `__add__` by name every time, rather than using the slot mechanism:
https://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/ https://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-t...
- ashconnor 6y agoThere's a great on this by the same author: https://www.youtube.com/watch?v=qCGofLIzX6g https://www.youtube.com/watch?v=qCGofLIzX6g