Re: Combine two dictionary...

2007-10-04 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Abandoned wrote: > I want to total score.. > For example >> > dict1={1: 4, 3: 5}... and 2 millions element >> > dict2={3: 3, 8: 6}... and 3 millions element > > result should be dict3={1:4, 3:8, 8:6} Don't people like one-liners? :) dict((k, dict1.get(k, 0)

Re: Combine two dictionary...

2007-10-04 Thread Paul Hankin
On Oct 4, 4:35 pm, Gary Coulbourne <[EMAIL PROTECTED]> wrote: > >>> dict1={1: 4, 3: 5}... and 2 millions element > >>> dict2={3: 3, 8: 6}... and 3 millions element > > If you don't mind doing some kind of lazy evaluation, you could do > something like... > > -- > dict1

Re: Combine two dictionary...

2007-10-04 Thread Gary Coulbourne
>>> dict1={1: 4, 3: 5}... and 2 millions element >>> dict2={3: 3, 8: 6}... and 3 millions element If you don't mind doing some kind of lazy evaluation, you could do something like... -- dict1={1:4, 3:5} dict2={3:3, 8:6} import UserDict class Merge(UserDict.DictMixi

Re: Combine two dictionary...

2007-10-02 Thread George Sakkis
On Oct 1, 2:01 pm, Abandoned <[EMAIL PROTECTED]> wrote: > I want to total score.. > For example > > > > dict1={1: 4, 3: 5}... and 2 millions element > > > dict2={3: 3, 8: 6}... and 3 millions element > > result should be dict3={1:4, 3:8, 8:6} Unless you have some prior knowledge about the dicts

Re: Combine two dictionary...

2007-10-01 Thread Tim Chase
>> I want to total score.. >> For example dict1={1: 4, 3: 5}... and 2 millions element dict2={3: 3, 8: 6}... and 3 millions element >> result should be dict3={1:4, 3:8, 8:6} > > Well not sure how this will work with 5+ million elements, but here's > one stab at it: > > >>> dict1

Re: Combine two dictionary...

2007-10-01 Thread Ian Clark
Abandoned wrote: > On 1 Ekim, 20:41, Carsten Haese <[EMAIL PROTECTED]> wrote: >> On Mon, 2007-10-01 at 10:24 -0700, Abandoned wrote: >>> Hi.. >>> dict1={1: 4, 3: 5}... and 2 millions element >>> dict2={3: 3, 8: 6}... and 3 millions element >>> I want to combine dict1 and dict2 and i don't want to

Re: Combine two dictionary...

2007-10-01 Thread Bruno Desthuilliers
Abandoned a écrit : > > I'm sorry my bed english. Time to go to bad, then !-) (sorry, couldn't resist) -- http://mail.python.org/mailman/listinfo/python-list

Re: Combine two dictionary...

2007-10-01 Thread Abandoned
On 1 Ekim, 20:41, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Mon, 2007-10-01 at 10:24 -0700, Abandoned wrote: > > Hi.. > > dict1={1: 4, 3: 5}... and 2 millions element > > dict2={3: 3, 8: 6}... and 3 millions element > > > I want to combine dict1 and dict2 and i don't want to use FOR because >

Re: Combine two dictionary...

2007-10-01 Thread Raymond Hettinger
On Oct 1, 10:24 am, Abandoned <[EMAIL PROTECTED]> wrote: > Hi.. > dict1={1: 4, 3: 5}... and 2 millions element > dict2={3: 3, 8: 6}... and 3 millions element > > I want to combine dict1 and dict2 and i don't want to use FOR because > i need to performance. The dict.update approach is the fastest

Re: Combine two dictionary...

2007-10-01 Thread Carsten Haese
On Mon, 2007-10-01 at 10:24 -0700, Abandoned wrote: > Hi.. > dict1={1: 4, 3: 5}... and 2 millions element > dict2={3: 3, 8: 6}... and 3 millions element > > I want to combine dict1 and dict2 and i don't want to use FOR because > i need to performance. You'll have to be a bit more precise here a

Re: Combine two dictionary...

2007-10-01 Thread Tim Chase
> dict1={1: 4, 3: 5}... and 2 millions element > dict2={3: 3, 8: 6}... and 3 millions element > > I want to combine dict1 and dict2 and i don't want to use FOR because > i need to performance. If you combine your dict1 and dict2 to become result_dict, what should the result of result_dict[3] b

Re: Combine two dictionary...

2007-10-01 Thread Stargaming
On Mon, 01 Oct 2007 10:24:39 -0700, Abandoned wrote: > Hi.. > dict1={1: 4, 3: 5}... and 2 millions element dict2={3: 3, 8: 6}... and > 3 millions element > > I want to combine dict1 and dict2 and i don't want to use FOR because i > need to performance. > > I'm sorry my bed english. > King rega

Combine two dictionary...

2007-10-01 Thread Abandoned
Hi.. dict1={1: 4, 3: 5}... and 2 millions element dict2={3: 3, 8: 6}... and 3 millions element I want to combine dict1 and dict2 and i don't want to use FOR because i need to performance. I'm sorry my bed english. King regards.. -- http://mail.python.org/mailman/listinfo/python-list