david jensen wrote:
> Hi all,
>
> I'm trying to find a good way of doing the following:
>
> Each n-tuple in combinations( range( 2 ** m ), n ) has a corresponding
> value n-tuple (call them "scores" for clarity later). I'm currently
> storing them in a dictionary, by doing:
>
>
> res={}
>
On 04/15/10 02:03, Paul Rubin wrote:
> Raymond Hettinger writes:
>> Not sure what the readability issue is. The phrase "nlargest(2,
>> iterable)" does exactly what it says, finds the 2 largest elements
>> from an iterable. That makes the programmer's intent more clear than
>> the slower, but sem
On Apr 14, 6:06 pm, Raymond Hettinger wrote:
> > I'm not sure a heap will help much, and at least to me,
> > doesn't improve readability.
>
> nlargest() should save quite a few comparisons and run much faster
> than sorted().
>
> Not sure what the readability issue is. The phrase "nlargest(2,
> i
> > Not sure what the readability issue is. The phrase "nlargest(2,
> > iterable)" does exactly what it says, finds the 2 largest elements
> > from an iterable. That makes the programmer's intent more clear than
> > the slower, but semanticly equivalent form: sorted(iterable)[:2].
>
> I think yo
Raymond Hettinger writes:
> Not sure what the readability issue is. The phrase "nlargest(2,
> iterable)" does exactly what it says, finds the 2 largest elements
> from an iterable. That makes the programmer's intent more clear than
> the slower, but semanticly equivalent form: sorted(iterable)[
> I'm not sure a heap will help much, and at least to me,
> doesn't improve readability.
nlargest() should save quite a few comparisons and run much faster
than sorted().
Not sure what the readability issue is. The phrase "nlargest(2,
iterable)" does exactly what it says, finds the 2 largest ele
On Apr 12, 1:22 am, Paul McGuire wrote:
> On Apr 9, 10:03 am, david jensen wrote:
>
>
>
> > Hi all,
>
> > I'm trying to find a good way of doing the following:
>
> > Each n-tuple in combinations( range( 2 ** m ), n ) has a corresponding
> > value n-tuple (call them "scores" for clarity later). I'
On Apr 11, 9:39 pm, Raymond Hettinger wrote:
> The overall algorithm looks about right.
> The inner-loop could be tighted-up a bit.
> And you could replace the outer sort with a heap.
>
> best2 = {}
> for i in itertools.combinations(range( 2**m), n-1):
> scorelist = []
> for j in range( 2
On Apr 9, 10:03 am, david jensen wrote:
> Hi all,
>
> I'm trying to find a good way of doing the following:
>
> Each n-tuple in combinations( range( 2 ** m ), n ) has a corresponding
> value n-tuple (call them "scores" for clarity later). I'm currently
> storing them in a dictionary, by doing:
>
>
On Apr 9, 8:03 am, david jensen wrote:
> Hi all,
>
> I'm trying to find a good way of doing the following:
>
> Each n-tuple in combinations( range( 2 ** m ), n ) has a corresponding
> value n-tuple (call them "scores" for clarity later). I'm currently
> storing them in a dictionary, by doing:
>
>
Hi all,
I'm trying to find a good way of doing the following:
Each n-tuple in combinations( range( 2 ** m ), n ) has a corresponding
value n-tuple (call them "scores" for clarity later). I'm currently
storing them in a dictionary, by doing:
res={}
for i in itertools.combinations( range( 2**
11 matches
Mail list logo