[Numpy-discussion] chararray behavior

Alan McIntyre alan.mcintyre at gmail.com
Tue Jul 8 13:53:24 EDT 2008


On Tue, Jul 8, 2008 at 1:29 PM, Travis E. Oliphant
<oliphant at enthought.com> wrote:
> Alan McIntyre wrote:
>> Since chararray doesn't currently have any tests, I'm writing some,
>> and I ran across a couple of things that didn't make sense to me:
>>
>> 1. The code for __mul__ is exactly the same as that for __rmul__; is
>> there any reason __rmul__ shouldn't just call __mul__?
>>
> Just additional function call overhead, but it's probably fine to just
> call __mul__.
>
>> 1.5. __radd__ seems like it doesn't do anything fundamentally
>> different from __add__, is there a reason to have a separate
>> implementation of __radd__?
>>
> Possibly.   I'm not sure.

I'll probably leave them alone; I was just curious, mostly.

>> 2. The behavior of __mul__ seems odd:
>>
> What is odd about this?
>
> It is patterned after
>
>  >>> 'a' * 3
>  >>> 'a' * 4
>  >>> 'a' * 5
>
> for regular python strings.

That's what I would have expected, but for N >= 4, Q*N is the same as Q*4.



More information about the NumPy-Discussion mailing list