Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(25)

Unified Diff: Lib/_collections_abc.py

Issue 26915: Test identity first in membership operation of ItemsView, ValuesView and Sequence in collections.abc
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/test/test_collections.py » ('j') | Lib/test/test_collections.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/_collections_abc.py Wed Jun 01 08:17:27 2016 +0000
+++ b/Lib/_collections_abc.py Sat Jun 04 16:39:52 2016 +0800
@@ -860,7 +860,8 @@
i = start
while stop is None or i < stop:
try:
- if self[i] == value:
+ v = self[i]
+ if v is value or v == value:
return i
except IndexError:
break
@@ -869,7 +870,7 @@
def count(self, value):
'S.count(value) -> integer -- return number of occurrences of value'
- return sum(1 for v in self if v == value)
+ return sum(1 for v in self if v is value or v == value)
Sequence.register(tuple)
Sequence.register(str)
« no previous file with comments | « no previous file | Lib/test/test_collections.py » ('j') | Lib/test/test_collections.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+