[Python-Dev] "Micro-optimisations can speed up CPython"

Steven D'Aprano steve at pearwood.info
Mon May 29 22:47:50 EDT 2017


On Mon, May 29, 2017 at 07:27:05PM -0700, Guido van Rossum wrote:

> > https://www.corsix.org/content/why-are-slots-so-slow
> >
> 
> Is the author of that article using non-standard terminology? The article
> doesn't appear to be about __slots__ at all.

Quoting Armin Ronacher:

    By far my biggest problem with the language is the stupid slot
    system. I do not mean the __slots__ but the internal type slots
    for special methods.

http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/

Armin shows the history of these "slots" (or however they're called) 
back to Python in 1990!

static number_methods int_as_number = {
    intadd, /*tp_add*/
    intsub, /*tp_subtract*/
    intmul, /*tp_multiply*/
    ... etc

I don't know where the name "slot" comes for from the various tp_* 
members (fields? attributes? slots?) but I'm pretty sure I've heard it 
before. I don't normally pay attention to what happens in the C 
implementation, but I'm fairly sure he's referring to these tp_* 
thingies.

Oh yes, here you go:

https://docs.python.org/2/extending/newtypes.html#type-methods

refers to "tp_* slot" regularly. What does "tp" stand for? Type 
something, I guess.


-- 
Steve


More information about the Python-Dev mailing list