In a comment to @unutbus answer I suggested np.delete. Here are a few timings
A larger test array:
In [445]: A=np.arange(1000)
@unutbu's answer:
In [446]: timeit A[~np.in1d(np.arange(len(A)), (np.r_[10:50:3,100:200,300:350]))].shape
1000 loops, best of 3: 454 µs per loop
Same index list, but using np.delete - about 3x speedup
In [447]: timeit np.delete(A,np.r_[10:50:3,100:200,300:350]).shape
10000 loops, best of 3: 166 µs per loop
But doing a straight forward boolean masking is even faster. Earlier I deduced that np.delete does basically this, but it must have some added overhead (including the ability to handle multiple dimensions):
In [448]: %%timeit
ind=np.ones_like(A,bool)
ind[np.r_[10:50:3,100:200,300:350]]=False
A[ind].shape
.....:
10000 loops, best of 3: 71.5 µs per loop
np.delete has a different strategy when the input is a slice, which may be faster than boolean indexing. But it only handles one slice at a time, hence the nested delete that @Kasramvd shows. I intend to add that timing.
Concatenating multiple slices is another option.
np.r_ also involves a loop, but it is only over the slices. Basically it iterates over the slices, expanding each as a range, and concatenates them. In my fastest case it is responsible for 2/3 of the run time:
In [451]: timeit np.r_[10:50:3,100:200,300:350]
10000 loops, best of 3: 41 µs per loop
In [453]: %%timeit x=np.r_[10:50:3,100:200,300:350]
ind=np.ones_like(A,bool)
ind[x]=False
A[ind].shape
.....:
10000 loops, best of 3: 24.2 µs per loop
The nested delete has pretty good performance:
In [457]: timeit np.delete( np.delete( np.delete(A,slice(300,350)),
slice(100,200)),slice(10,50,3)).shape
10000 loops, best of 3: 108 µs per loop
np.delete, when given a slice to delete, copies slices to the result array (the blocks before and after the delete block). I can approximate that by concatenating several slices. I'm cheating here by using delete for the 1st block, rather than take the time to write a pure copy. Still it is faster than the best boolean mask expression.
In [460]: timeit np.concatenate([np.delete(A[:100],slice(10,50,3)),
A[200:300],A[350:]]).shape
10000 loops, best of 3: 65.7 µs per loop
I can remove the delete with this slicing, though the order of the 10:50 range is messed up. I suspect that this is, theoretically, the fastest:
In [480]: timeit np.concatenate([A[:10], A[11:50:3], A[12:50:3],
A[50:100], A[200:300], A[350:]]).shape
100000 loops, best of 3: 16.1 µs per loop
An important caution - these alternatives are being tested with non-overlapping slices. Some may work with overlaps, others might not.
X[0:3],X[6:9].x[12:15]?np.r_do that, another repeatedly usesdelete, yet another combines slices.