for sharing your thoughts with me.
Regards,
Malcolm
- Original message -
From: Roger Binns rog...@rogerbinns.com
To: python-list@python.org
Date: Tue, 23 Dec 2008 23:26:49 -0800
Subject: Re: Strategy for determing difference between 2 very large
dictionaries
-BEGIN PGP SIGNED
with. Your dictionary comprehension statement describes
exactly what I wanted to write.
Regards,
Malcolm
- Original message -
From: Gabriel Genellina gagsl-...@yahoo.com.ar
To: python-list@python.org
Date: Wed, 24 Dec 2008 05:46:04 -0200
Subject: Re: Strategy for determing difference between
On Wed, 24 Dec 2008 03:23:00 -0500, python wrote:
Hi Gabriel,
Thank you very much for your feedback!
k1 = set(dict1.iterkeys())
I noticed you suggested .iterkeys() vs. .keys(). Is there any advantage
to using an iterator vs. a list as the basis for creating a set? I
understand that an
you!
Malcolm
- Original message -
From: Marc 'BlackJack' Rintsch bj_...@gmx.net
To: python-list@python.org
Date: 24 Dec 2008 08:30:41 GMT
Subject: Re: Strategy for determing difference between 2 very large
dictionaries
On Wed, 24 Dec 2008 03:23:00 -0500, python wrote:
Hi
Gabriel Genellina wrote:
En Wed, 24 Dec 2008 05:16:36 -0200, pyt...@bdurham.com escribió:
[I didn't see the original post]
I'm looking for suggestions on the best ('Pythonic') way to
determine the difference between 2 very large dictionaries
containing simple key/value pairs.
By
Marc 'BlackJack' Rintsch wrote:
On Wed, 24 Dec 2008 03:23:00 -0500, python wrote:
Hi Gabriel,
Thank you very much for your feedback!
k1 = set(dict1.iterkeys())
I noticed you suggested .iterkeys() vs. .keys(). Is there any advantage
to using an iterator vs. a list as the basis for creating
Hi James,
For the purpose of perpetuating the annoying pedantry that has made
usenet great:
http://docs.python.org/dev/3.0/whatsnew/3.0.html#views-and-iterators-instead-of-lists
Great tip! Thank you!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
En Wed, 24 Dec 2008 06:23:00 -0200, pyt...@bdurham.com escribió:
Hi Gabriel,
Thank you very much for your feedback!
k1 = set(dict1.iterkeys())
I noticed you suggested .iterkeys() vs. .keys(). Is there any advantage
to using an iterator vs. a list as the basis for creating a set? I
You've
for sharing that technique.
Regards,
Malcolm
- Original message -
From: Peter Otten __pete...@web.de
To: python-list@python.org
Date: Wed, 24 Dec 2008 09:46:51 +0100
Subject: Re: Strategy for determing difference between 2 very large
dictionaries
Gabriel Genellina wrote:
En Wed, 24
: Strategy for determing difference between 2 very large
dictionaries
En Wed, 24 Dec 2008 06:23:00 -0200, pyt...@bdurham.com escribió:
Hi Gabriel,
Thank you very much for your feedback!
k1 = set(dict1.iterkeys())
I noticed you suggested .iterkeys() vs. .keys(). Is there any advantage
Peter Otten:
a = dict(a=1, b=2, c=3)
b = dict(b=2, c=30, d=4)
dict(set(a.iteritems()) ^ set(b.iteritems()))
For larger sets this may be better, may avoid the creation of the
second set:
dict(set(a.iteritems()).symmetric_difference(b.iteritems()))
Bye,
bearophile
--
Gabriel Genellina wrote:
En Wed, 24 Dec 2008 06:23:00 -0200, pyt...@bdurham.com escribió:
... k1 = set(dict1.iterkeys())
You've got an excelent explanation from Marc Rintsch. (Note that in
Python 3.0 keys() behaves as iterkeys() in previous versions, so the
above code is supposed to be
Marc 'BlackJack' Rintsch wrote:
On Wed, 24 Dec 2008 03:23:00 -0500, python wrote:
collection, I don't see the advantage of using an iterator or a list.
I'm sure I'm missing a subtle point here :)
`keys()` creates a list in memory, `iterkeys()` does not. With
``set(dict.keys())`` there is a
On Dec 24, 7:04 pm, Malcolm Greene mgre...@bdurham.com wrote:
Hi Roger,
By very large dictionary, I mean about 25M items per dictionary. Each
item is a simple integer whose value will never exceed 2^15.
In Python-speak about dictionaries, an item is a tuple (key, value).
I presume from the
I'm looking for suggestions on the best ('Pythonic') way to
determine the difference between 2 very large dictionaries
containing simple key/value pairs.
By difference, I mean a list of keys that are present in the
first dictionary, but not the second. And vice versa. And a list
of keys in common
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
pyt...@bdurham.com wrote:
Feedback on my proposed strategies (or better strategies) would be
greatly appreciated.
Both strategies will work but I'd recommend the second approach since it
uses already tested code written by other people - the
En Wed, 24 Dec 2008 05:16:36 -0200, pyt...@bdurham.com escribió:
I'm looking for suggestions on the best ('Pythonic') way to
determine the difference between 2 very large dictionaries
containing simple key/value pairs.
By difference, I mean a list of keys that are present in the
first
On Tue, Dec 23, 2008 at 11:46 PM, Gabriel Genellina
gagsl-...@yahoo.com.ar wrote:
snip
Yes; but isn't a dict comprehension more adequate?
[key: (dict1[key], dict2[key]) for key in common_keys if
dict1[key]!=dict2[key]}
nitpick severity=minor
That initial [ should be a { of course.
Cheers,
18 matches
Mail list logo