[SciPy-user] operations on int8 arrays

Fernando Perez Fernando.Perez at colorado.edu
Wed Oct 19 18:24:39 CDT 2005


Travis Oliphant wrote:
> One issue, though.  Upcasting to a different type will be slower.

It may be slower, but for the very small types, (8-bit), not upcasting is 
almost guaranteed to be wrong.  That's why I think that the case of 
accumulators deserves special treatment: without it, the functions are 
time-bombs waiting to go off (and they have in the past, as we've seen on this 
list multiple times).  For wider types you are obviously less likely to hit 
the problem, but for small ones it is very acute.

People who know that they are adding less than 256 unsigned 8-bit integers, 
all so small that their sum can't be > 255 (and I don't know how they can know 
this in advance) could always call the routine with rtype=uint8.  Most people 
would rather get the numerically correct answer, rather than the mysterious 
'sum() % 255', which is effectively what the code does today.

Anyway, I've stated my case to the best of my ability.  If a choice is made 
not to upcast, I'll just get used to keeping a locally overridden sum() for my 
own usage, which isn't a blade without a handle.

Cheers,

f



More information about the SciPy-user mailing list