On Apr 30, 12:37 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> [Prateek]
>
> > The reason why I'm casting to a list first is because I found that
> > creating a long list which I convert to a set in a single operation is
> > faster (although probably less memory efficient - which I can deal
>
[Prateek]
> The reason why I'm casting to a list first is because I found that
> creating a long list which I convert to a set in a single operation is
> faster (although probably less memory efficient - which I can deal
> with) than doing all the unions.
That would be a surprising result because
[Prateek]
> I have 3 variable length lists of sets. I need to find the common
> elements in each list (across sets) really really quickly.
. . .
> l1 = reduce(operator.add, list(x) for x in l1)
> l2 = reduce(operator.add, list(x) for x in l2)
> l3 = reduce(operator.add, list(x) for x in l3)
> s = f
Prateek <[EMAIL PROTECTED]> wrote:
> > For the above example, it's worth sorting lists_of_sets by the
> > length of the sets, and doing the short ones first.
>
> Thanks. I thought so - I'm doing just that using a simple Decorate-
> Sort-Undecorate idiom.
Use, instead, the DSU that is now bu
Prateek <[EMAIL PROTECTED]> writes:
> The big set does stay around for a while - I've implemented an LRU
> based caching algorithm on the code that does the I/O. Since the db is
> transactioned, I keep one copy in the current transaction cache (which
> is a simple dictionary) and one in the main re
On Apr 30, 5:08 am, John Nagle <[EMAIL PROTECTED]> wrote:
> Prateek wrote:
> >> For the above example, it's worth sorting lists_of_sets by the
> >>length of the sets, and doing the short ones first.
>
> > Thanks. I thought so - I'm doing just that using a simple Decorate-
> > Sort-Undecorate id
Prateek wrote:
>> For the above example, it's worth sorting lists_of_sets by the
>>length of the sets, and doing the short ones first.
>
>
> Thanks. I thought so - I'm doing just that using a simple Decorate-
> Sort-Undecorate idiom.
>
>
>> How big are the sets? If they're small, but y
On Apr 30, 3:48 am, James Stroud <[EMAIL PROTECTED]> wrote:
> Prateek wrote:
> > I have 3 variable length lists of sets. I need to find the common
> > elements in each list (across sets) really really quickly.
>
> > Here is some sample code:
>
> > # Doesn't make sense to union the sets - we're goin
> For the above example, it's worth sorting lists_of_sets by the
> length of the sets, and doing the short ones first.
Thanks. I thought so - I'm doing just that using a simple Decorate-
Sort-Undecorate idiom.
> How big are the sets? If they're small, but you have a lot of
> them, you
James Stroud wrote:
> Prateek wrote:
>
>> I have 3 variable length lists of sets. I need to find the common
>> elements in each list (across sets) really really quickly.
>>
>> Here is some sample code:
>>
>> # Doesn't make sense to union the sets - we're going to do
>> intersections later anyway
>
Prateek wrote:
> I have 3 variable length lists of sets. I need to find the common
> elements in each list (across sets) really really quickly.
>
> Here is some sample code:
>
> # Doesn't make sense to union the sets - we're going to do
> intersections later anyway
> l1 = reduce(operator.add, lis
I have 3 variable length lists of sets. I need to find the common
elements in each list (across sets) really really quickly.
Here is some sample code:
# Doesn't make sense to union the sets - we're going to do
intersections later anyway
l1 = reduce(operator.add, list(x) for x in l1)
l2 = reduce(o
12 matches
Mail list logo