gh-102088 Optimize iter_index itertools recipe (GH-102360)

This commit is contained in:
Stefan Pochmann 2023-03-02 04:16:23 +01:00 committed by GitHub
parent 2f62a5da94
commit eaae563b68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -208,6 +208,9 @@ class OperatorTestCase:
nan = float("nan")
self.assertEqual(operator.indexOf([nan, nan, 21], nan), 0)
self.assertEqual(operator.indexOf([{}, 1, {}, 2], {}), 0)
it = iter('leave the iterator at exactly the position after the match')
self.assertEqual(operator.indexOf(it, 'a'), 2)
self.assertEqual(next(it), 'v')
def test_invert(self):
operator = self.module