[Python-Dev] Slot for trunc (original) (raw)

Guido van Rossum guido at python.org
Tue Jan 29 21:04:15 CET 2008


On Jan 29, 2008 11:34 AM, Raymond Hettinger <python at rcn.com> wrote:

[GvR] > I don't see why. index has a slot because its > primary use is to be called from C code, where slots > add a slight performance advantage. > trunc doesn't get called from C AFAIK.

I thought the trunc method only gets called from the C code for the trunc() function which is currently implemented with PyObjectCallMethod(number, "trunc", "") instead of a fast call to a slot.

I see.

Well, it would bounce around a bit but it would never execute Python byte codes. I don't see trunc() being all that performance critical. The cost of adding a new slot is considerable -- for one, all type objects become 4 (or 8) bytes longer.

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list