bpo-26915: Test identity first in membership operation in index() and count() methods of collections.abc.Sequence (GH-503)


diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index b172f3f..005d884 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -908,7 +908,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
@@ -917,7 +918,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)