On Wed, Jul 21, 2010 at 8:24 PM, Charles R Harris <charlesr.har...@gmail.com> wrote: > > On Wed, Jul 21, 2010 at 5:44 PM, Keith Goodman <kwgood...@gmail.com> wrote:
>> Can someone confirm that the copy in np.linalg.lstsq >> >> bstar[:b.shape[0],:n_rhs] = b.copy() >> >> is not needed? I'm assuming that ndarray.__setitem__ never gives a >> view of the right-hand side. >> ________ > > bstar doesn't share memory with b, so there is no need for a copy. The whole > first part of lstsq could use a cleanup, there are a lot of other things > that could be made cleaner and some other bits that don't look right. Anyone > want to take a shot at it? > > Chuck Some minor tweaks suggestions: >> b = np.random.rand(1000) >> timeit b[:,newaxis] # actual 1000000 loops, best of 3: 1.03 us per loop >> timeit b.reshape(-1,1) # alternative 1000000 loops, best of 3: 445 ns per loop >> >> timeit len(b.shape) # actual 10000000 loops, best of 3: 145 ns per loop >> timeit b.ndim # alternative 10000000 loops, best of 3: 74.1 ns per loop _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion