summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2020-05-28 15:35:46 (GMT)
committerGitHub <noreply@github.com>2020-05-28 15:35:46 (GMT)
commit60398512c86c5535edd817c99ccb50453b3b0471 (patch)
treee2ce7e054b2cc0a81ddd5bb94a33f3b3369d9937 /Doc
parent0de437de6210c2b32b09d6c47a805b23d023bd59 (diff)
downloadcpython-60398512c86c5535edd817c99ccb50453b3b0471.zip
cpython-60398512c86c5535edd817c99ccb50453b3b0471.tar.gz
cpython-60398512c86c5535edd817c99ccb50453b3b0471.tar.bz2
bpo-40755: Add missing multiset operations to Counter() (GH-20339)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/collections.rst41
1 files changed, 41 insertions, 0 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 549ac1b..ea2b420 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -290,6 +290,47 @@ For example::
>>> sorted(c.elements())
['a', 'a', 'a', 'a', 'b', 'b']
+ .. method:: isdisjoint(other)
+
+ True if none of the elements in *self* overlap with those in *other*.
+ Negative or missing counts are ignored.
+ Logically equivalent to: ``not (+self) & (+other)``
+
+ .. versionadded:: 3.10
+
+ .. method:: isequal(other)
+
+ Test whether counts agree exactly.
+ Negative or missing counts are treated as zero.
+
+ This method works differently than the inherited :meth:`__eq__` method
+ which treats negative or missing counts as distinct from zero::
+
+ >>> Counter(a=1, b=0).isequal(Counter(a=1))
+ True
+ >>> Counter(a=1, b=0) == Counter(a=1)
+ False
+
+ Logically equivalent to: ``+self == +other``
+
+ .. versionadded:: 3.10
+
+ .. method:: issubset(other)
+
+ True if the counts in *self* are less than or equal to those in *other*.
+ Negative or missing counts are treated as zero.
+ Logically equivalent to: ``not self - (+other)``
+
+ .. versionadded:: 3.10
+
+ .. method:: issuperset(other)
+
+ True if the counts in *self* are greater than or equal to those in *other*.
+ Negative or missing counts are treated as zero.
+ Logically equivalent to: ``not other - (+self)``
+
+ .. versionadded:: 3.10
+
.. method:: most_common([n])
Return a list of the *n* most common elements and their counts from the