[Python-Dev] Fwd: summing a bunch of numbers (or "whatevers")

Ludovic Aubry Ludovic.Aubry@logilab.fr
Wed, 23 Apr 2003 10:44:19 +0200


On Mon, Apr 21, 2003 at 05:23:25PM -0400, Raymond Hettinger wrote:
> [RH]
> > For the C implementation, consider bypassing operator.add
> > and calling the nb_add slot directly.  It's faster and fulfills
> > the intention to avoid the alternative call to sq_concat.
> 
> Forget I said that, you still need PyNumber_Add() to
> handle coercion and such.  Though without some
> special casing  it's going to be darned difficult to match 
> the performance of a pure python for-loop (especially
> for a sequence of integers).

Why not move the integer add optimization from ceval.c into PyNumber_Add
?
Granted you have an extra call on the fast path, but on the other hand
* more code could benefit from this optimization
* you don't have code related to the same operation spread in several
  files
* the ceval loop has a reduced footprint



-- 
Ludovic Aubry                                 LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org