[Numpy-discussion] Extracting all the possible combinations of a grid
Gary Ruben
gruben at bigpond.net.au
Fri Sep 21 21:33:39 EDT 2007
Gael Varoquaux wrote:
> On Fri, Sep 21, 2007 at 02:58:43PM -0600, Charles R Harris wrote:
>> I found generators a good approach to this sort of thing:
>
>> for (i,j,k) in triplets(n) :
>
> That's what we where doing so far, but in the code itself. The result was
> unbearably slow.
> I think for our purposes we should build a precalculated table of these
> nuplets, and then do array calculations on them.
I'm not sure whether this helps, but I have found this generator-based
recipe <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465>
very useful in the past. The comment "If you require the complete list
of permutations, just use the built-in list() operator" may apply to
your situation,
Gary R.
More information about the NumPy-Discussion
mailing list