homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients ezio.melotti, michael.foord, rhettinger
Date 2010年11月03日.23:06:46
SpamBayes Score 0.00063865335
Marked as misclassified No
Message-id <1288825608.51.0.870131650343.issue10242@psf.upfronthosting.co.za>
In-reply-to
Content
Suggestions:
* new name: assertCountEqual(a, b)
 or: assertElementCountEqual(a, b)
 this name captures the essential service:
 - unordered comparison where duplicates matter
 - inputs are "elements", 
 not "items" which means key/value pairs
* O(n) implementation with O(n**2) fallback:
 try:
 a_cnt = collections.Counter(a)
 b_cnt = collections.Counter(b)
 except TypeError:
 # do current O(n**2) fallback
 else:
 if a_cnt == b_cnt:
 # test passed
 else:
 in_a_but_not_in_b = a - b
 in_b_but_not_in_a = b - a
 # display nice diff
* documentation should emphasize the new name:
 assertElementCountEqual(a, b)
 obsolete alias: assertItemsEqual(a, b)
History
Date User Action Args
2010年11月03日 23:06:48rhettingersetrecipients: + rhettinger, ezio.melotti, michael.foord
2010年11月03日 23:06:48rhettingersetmessageid: <1288825608.51.0.870131650343.issue10242@psf.upfronthosting.co.za>
2010年11月03日 23:06:47rhettingerlinkissue10242 messages
2010年11月03日 23:06:46rhettingercreate

AltStyle によって変換されたページ (->オリジナル) /