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

Guido van Rossum guido at python.org
Mon May 29 23:41:26 EDT 2017


<Blush>

tp_ stands for "type". I wrote all that in 1990 and indeed made up the term
slot -- it's like an entry in a C++ vtable, where apparently they are also
called slots by some folks. I also did a major update to the machinery here
in the early 2000s (when typeobject.c grew from 50 lines to 5000) but
didn't update the terminology.

I feel a bit offended that Armin calls it "the stupid slot system" -- this
architecture an important part of what makes C extensions so flexible. I
will happily see it replaced by something better, if it can be found, but I
don't think it's fair to call it "stupid". However I no longer am
interested in maintaining that code myself, and I can't bear to read those
blog posts (they're rambling and sound like someone's research notes).

On Mon, May 29, 2017 at 7:47 PM, Steven D'Aprano <steve at pearwood.info>
wrote:

> 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
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170529/8cd6cb4e/attachment.html>


More information about the Python-Dev mailing list