kwgoodman/la — Issue #54: Avoid copy to speed up larry.__rdiv__()
Author: kwgoodman
Created: 2012-03-08 21:11:53+00:00
State: open

Old:

I[1] lar = la.rand(1000, 1000)
I[2] timeit 1.0 / lar
100 loops, best of 3: 10 ms per loop
I[3] lar = la.rand(10, 10)
I[4] timeit 1.0 / lar
100000 loops, best of 3: 6.25 us per loop

New:

I[1] lar = la.rand(1000, 1000)
I[2] timeit 1.0 / lar
100 loops, best of 3: 5.04 ms per loop
I[3] lar = la.rand(10, 10)
I[4] timeit 1.0 / lar
100000 loops, best of 3: 5.42 us per loop

Old:

if np.isscalar(other) or isinstance(other, np.ndarray):
y = self.copy()
y.x = other / y.x
return y

New:

if np.isscalar(other) or isinstance(other, np.ndarray):
label = self.copylabel()
x = other / self.x
return larry(x, label, validate=False)