]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Expand the implementation comments (GH-19699)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Fri, 24 Apr 2020 09:33:07 +0000 (02:33 -0700)
committerGitHub <noreply@github.com>
Fri, 24 Apr 2020 09:33:07 +0000 (02:33 -0700)
Lib/collections/__init__.py

index bb9a605a994f4660329c51fb406c3933d36c6a9d..c4bff592dc0e71d14b9bde675ca92f304bee6e68 100644 (file)
@@ -711,6 +711,13 @@ class Counter(dict):
     #
     # To strip negative and zero counts, add-in an empty counter:
     #       c += Counter()
+    #
+    # Rich comparison operators for multiset subset and superset tests
+    # are deliberately omitted due to semantic conflicts with the
+    # existing inherited dict equality method.  Subset and superset
+    # semantics ignore zero counts and require that p≤q ∧ p≥q → p=q;
+    # however, that would not be the case for p=Counter(a=1, b=0)
+    # and q=Counter(a=1) where the dictionaries are not equal.
 
     def __add__(self, other):
         '''Add counts from two counters.