[Numpy-discussion] Faster

Keith Goodman kwgoodman@gmail....
Fri May 2 19:24:53 CDT 2008


How can I make this function faster? It removes the i-th row and
column from an array.

def cut(x, i):
    idx = range(x.shape[0])
    idx.remove(i)
    y = x[idx,:]
    y = y[:,idx]
    return y

>> import numpy as np
>> x = np.random.rand(500,500)
>> timeit cut(x, 100)
100 loops, best of 3: 16.8 ms per loop


More information about the Numpy-discussion mailing list