[Numpy-discussion] "Manually" broadcasting arrays in Python

Robert Kern robert.kern at gmail.com
Wed Oct 4 00:33:05 CDT 2006


A. M. Archibald wrote:
> On 03/10/06, Robert Kern <robert.kern at gmail.com> wrote:
>> Has anyone implemented an easier or more efficient way to broadcast arrays to a
>> common shape at the Python level? I was hoping that the broadcast iterator would
>> actually provide the broadcasted arrays, but it does not.
> 
> How about vectorize(lambda *args: args)? Almost works, only it
> sometimes segfaults with more than two arguments... but that's clearly
> a numpy bug.

Yeah, a segfault would be problematic. Otherwise, it works and is in fact faster 
than what I wrote.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco





More information about the Numpy-discussion mailing list