[MATRIX-SIG] random number generator?

Geoffrey Furnish furnish@acl.lanl.gov
Wed, 29 Oct 1997 09:02:17 -0700 (MST)


David J. C. Beach writes:
 > > PPS: Is there really no += operator in Python?
 > 
 > Yup, no += operator.  Python's designers (Guido and others) opted not to
 > use many of the "fancy" operators from c and c++ that make it so easy to
 > get yourself in trouble...  Among these, +=, -=, *=, /=, ++, and --.
 > 
 > One might argue that writing a=a+1 is a bit more work than writing a+=1
 > or a++, but then again, Python is a whole lot easier to read and is more
 > consistent (IMHO) than either c or c++.  Having more operators is not
 > necessiarly a good thing.

Speed is the most important counter argument, imo, and one which ought
to be of considerable concern to NumPy customers.  I have previously
done timing tests between loops containing expressions like:

	a[i] = a[i] + x[i];

versus

	a[i] += x[i]; 

in C and C++.  The += form was as much as 20% faster on some tests on
some architectures.

Frankly, for a language litered with "self." on nearly every line, it
is very hard for me to buy that "a = a + 1" is syntactically more
beautiful.  It certainly is slower.

-- 
Geoffrey Furnish                email: furnish@lanl.gov
LANL CIC-19 POOMA/RadTran       phone: 505-665-4529     fax: 505-665-7880

"Software complexity is an artifact of implementation."    -Dan Quinlan

_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________