2 Oct 2000 19:57
quick optimization
Pete Shinners <pete <at> shinners.org>
2000-10-02 17:57:55 GMT
2000-10-02 17:57:55 GMT
i've got a quick optimization for the arrayobject.c source.
it speeds my usage of numpy up by about 100%. i've tested with
other numpy apps and noticed a minimum of about 20% speed.
anyways, in "do_sliced_copy", change out the following block:
if (src_nd == 0 && dest_nd == 0) {
for(j=0; j<copies; j++) {
memcpy(dest, src, elsize);
dest += elsize;
}
return 0;
}
with this slightly larger one:
if (src_nd == 0 && dest_nd == 0) {
switch(elsize) {
case sizeof(char):
memset(dest, *src, copies);
break;
case sizeof(short):
for(j=copies; j; --j, dest += sizeof(short))
*(short*)dest = *(short*)src;
break;
case sizeof(long):
for(j=copies; j; --j, dest += sizeof(int))
*(int*)dest = *(int*)src;
break;
case sizeof(double):
(Continue reading)
RSS Feed