[Python-Dev] Silly little benchmark

Guido van Rossum guido@digicool.com
Thu, 12 Jul 2001 21:16:16 -0400

> > """It looks like the new coercion rules have optimized number ops at the
> > expense of string ops.
> Is there still an intention to get rid of centralised
> coercion and move it all into the relevant methods?

This has been done (except for complex).

> If that were done, wouldn't problems like this go
> away (or at least turn into a different set of
> problems)?

I'm not sure what that remark refers to, actually.

BINARY_ADD and BINARY_SUBTRACT just test if both args are ints and
then in-line the work; BINARY_SUBSCRIPT does the same thing for
list[int].  I don't think it has anything to do with coercions.  When
the operands are strings, the costs are one pointer deref + compare to
link-time constant, and one jump (over the inlined code).

Small things add up, but I doubt that this is responsible for any
particular slow-down.

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