Slow String Repeat (was: [Python-Dev] PyBuffer* vs. array.array())

Raymond Hettinger python@rcn.com
Mon, 6 Jan 2003 09:50:07 -0500


From: "Christian Tismer" <tismer@tismer.com>

> I could imagine not to change string repeat and
> others, but the abstract implementation of the
> repetition of a sequence.
> An algorithm like the above could be written
> for general sequences, and do this break-up
> on the abstract level, once and for all
> repetitions of arbitrary objects.

Something similar can be done for arraymodule.c
The use cases there may involve longer than normal
repetition counts so some attention should be paid
to cache invalidation.

In other places, there is less of an opportunity since
replication involves more than copying (there are
Py_INCREFs to worry about).


Raymond Hettinger