[Numpy-discussion] numpy.random.shuffle

Christopher Barker Chris.Barker at noaa.gov
Wed Nov 22 13:14:33 CST 2006

Robert Kern wrote:
> I don't want to assume that the only two sequence types are lists and arrays.

Does numpy.random.shuffle really have to work on any sequence? and 
without making a copy? I'm not so sure -- having num* functions operate 
on any sequence has been a design goal of Numeric from the beginning, 
but I've never thought it that important.

However, it is pretty consistent across numpy, so we should probably 
support it here.

How about two cases:

1) sequences that support copy()
2) sequences that don't -- in that case, it is assumed that indexing has 
copy semantics.

It truth, this means:
1) numpy arrays
2) standard python mutable sequences

But it does satisfy the duck typing approach.

Maybe we could specifically check for copy vs. view semantics, but that 
seems like overkill.


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov

More information about the Numpy-discussion mailing list