Combine two dictionary...

Carsten Haese carsten at uniqsys.com
Mon Oct 1 13:41:15 EDT 2007


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 about how and where you want
to "combine". Should the result be a new dictionary or should it replace
one of dict1 or dict2? You're also not saying how you want conflicts
between dict1 and dict2 should be resolved. For example, both dict1 and
dict2 say something about the key 3. One says 5, the other says 3.
Should the combined dict say 3 or 5 or (3,5) or maybe even 4?

Also, based on your earlier posts from today, I'm wondering if those
dicts come from executing SQL queries. If so, you might want to consider
combining the results in SQL (using a UNION query) instead of combining
them in Python.

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list