[Numpy-discussion] Faster way to generate a rotation matrix?

Robert Kern robert.kern@gmail....
Wed Mar 4 00:58:54 CST 2009

On Wed, Mar 4, 2009 at 00:56, David Warde-Farley <dwf@cs.toronto.edu> wrote:
> On 3-Mar-09, at 11:41 PM, Jonathan Taylor wrote:
>> def rotation(theta, R = np.zeros((3,3))):
> Hey Jon,
> Just a note, in case you haven't heard this schpiel before: be careful
> when you use mutables as default arguments. It can lead to unexpected
> behaviour down the line.
> The reason is that the np.zeros() is only called once when the
> function is read by the interpreter, and that reference is retained
> between calls.

I'm pretty sure that's exactly why he did it, and that's what he's calling evil.

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