[Numpy-discussion] chararray behavior

Alan McIntyre alan.mcintyre@gmail....
Tue Jul 8 12:53:24 CDT 2008


On Tue, Jul 8, 2008 at 1:29 PM, Travis E. Oliphant
<oliphant@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