summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2011-10-23 18:53:01 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2011-10-23 18:53:01 (GMT)
commit36645681c8ad9a30d142f1dabb44d1d6c3ed5fab (patch)
treeb98250ba008c4e858e44563e12f232d5ccfb8dd9 /Doc
parenta2a2e480f335b8758a159ea72ab0067127d1d303 (diff)
downloadcpython-36645681c8ad9a30d142f1dabb44d1d6c3ed5fab.zip
cpython-36645681c8ad9a30d142f1dabb44d1d6c3ed5fab.tar.gz
cpython-36645681c8ad9a30d142f1dabb44d1d6c3ed5fab.tar.bz2
Issue #13201: equality for range objects is now based on equality of the underlying sequences. Thanks Sven Marnach for the patch.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/functions.rst12
-rw-r--r--Doc/whatsnew/3.3.rst6
2 files changed, 18 insertions, 0 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 886cb82..6944e1d 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1077,6 +1077,13 @@ are always available. They are listed here in alphabetical order.
>>> r[-1]
18
+ Testing range objects for equality with ``==`` and ``!=`` compares
+ them as sequences. That is, two range objects are considered equal if
+ they represent the same sequence of values. (Note that two range
+ objects that compare equal might have different :attr:`start`,
+ :attr:`stop` and :attr:`step` attributes, for example ``range(0) ==
+ range(2, 1, 3)`` or ``range(0, 3, 2) == range(0, 4, 2)``.)
+
Ranges containing absolute values larger than :data:`sys.maxsize` are permitted
but some features (such as :func:`len`) will raise :exc:`OverflowError`.
@@ -1086,6 +1093,11 @@ are always available. They are listed here in alphabetical order.
Test integers for membership in constant time instead of iterating
through all items.
+ .. versionchanged:: 3.3
+ Define '==' and '!=' to compare range objects based on the
+ sequence of values they define (instead of comparing based on
+ object identity).
+
.. function:: repr(object)
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
index d08ee62..95a5583 100644
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -186,6 +186,12 @@ and :func:`unicodedata.lookup()` resolves named sequences too.
(Contributed by Ezio Melotti in :issue:`12753`)
+Equality comparisons on :func:`range` objects now return a result reflecting
+the equality of the underlying sequences generated by those range objects.
+
+(:issue:`13021`)
+
+
New, Improved, and Deprecated Modules
=====================================