Index: arraymodule.c =================================================================== --- arraymodule.c (revision 52084) +++ arraymodule.c (working copy) @@ -667,7 +667,7 @@ static PyObject * array_repeat(arrayobject *a, Py_ssize_t n) { - Py_ssize_t i; + Py_ssize_t shift; Py_ssize_t size; arrayobject *np; char *p; @@ -680,10 +680,26 @@ return NULL; p = np->ob_item; nbytes = a->ob_size * a->ob_descr->itemsize; - for (i = 0; i < n; i++) { - memcpy(p, a->ob_item, nbytes); - p += nbytes; - } + + if (n == 0) + return (PyObject *) np; + + /* Extend the array using iterative doubling up to the nearest + lower power of two. */ + memcpy(np->ob_item, a->ob_item, nbytes); + shift = 0; + while (2<ob_item + (nbytes<ob_item, nbytes<ob_item + (nbytes<ob_item, n*nbytes); + return (PyObject *) np; }