diff options
author | sasha <sasha@localhost> | 2006-03-01 03:41:58 +0000 |
---|---|---|
committer | sasha <sasha@localhost> | 2006-03-01 03:41:58 +0000 |
commit | b25ddc20561f810283b7a6ecb49910f45df9770d (patch) | |
tree | 2bb1dffd738b69d1cc41533fe7fb659e349e413a /numpy/core/src/arrayobject.c | |
parent | 8f6eca691ad76cf0264ed9c8e2893e9160efe990 (diff) | |
download | numpy-b25ddc20561f810283b7a6ecb49910f45df9770d.tar.gz |
faster ndarray.fill
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 55abc36f0..cd83f31e1 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -4108,9 +4108,17 @@ PyArray_FillWithScalar(PyArrayObject *arr, PyObject *obj) copyswap = arr->descr->f->copyswap; if (PyArray_ISONESEGMENT(arr)) { char *toptr=PyArray_DATA(arr); - while (size--) { - copyswap(toptr, fromptr, swap, itemsize); - toptr += itemsize; + PyArray_FillWithScalarFunc* fillwithscalar = + arr->descr->f->fillwithscalar; + if (fillwithscalar && PyArray_ISALIGNED(arr)) { + copyswap(fromptr, NULL, swap, itemsize); + fillwithscalar(toptr, size, itemsize, fromptr); + } + else { + while (size--) { + copyswap(toptr, fromptr, swap, itemsize); + toptr += itemsize; + } } } else { |