Variant of operator.itemgetter that supports equality tests
| 1241 | |
| 1242 | |
| 1243 | class itemgetter: |
| 1244 | """Variant of operator.itemgetter that supports equality tests""" |
| 1245 | |
| 1246 | __slots__ = ("index",) |
| 1247 | |
| 1248 | def __init__(self, index): |
| 1249 | self.index = index |
| 1250 | |
| 1251 | def __call__(self, x): |
| 1252 | return x[self.index] |
| 1253 | |
| 1254 | def __reduce__(self): |
| 1255 | return (itemgetter, (self.index,)) |
| 1256 | |
| 1257 | def __eq__(self, other): |
| 1258 | return type(self) is type(other) and self.index == other.index |
| 1259 | |
| 1260 | |
| 1261 | class MethodCache: |
no outgoing calls