Christopher Barker wrote: > 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.
I think it is for this one function. I want numpy.random to be able to have all of the functionality of the stdlib's random module (although not as a drop-in replacement). The reason is that random number generation is something that should be completely and centrally controllable. I should be able to write my application such that it seeds the PRNG state *once* and uses that state everywhere. If I need to keep instances of both numpy.random.RandomState and random.Random around, then something's wrong. > However, it is pretty consistent across numpy, so we should probably > support it here. > > How about two cases: > > 1) sequences that support copy() It's not the container sequences would support a .copy() method, but the indexed items. > 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. It's also probably impossible. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
