gh-117431: Adapt str.find and friends to Argument Clinic (#117468)

This change gives a significant speedup, as the METH_FASTCALL calling
convention is now used. The following methods are adapted:

- str.count
- str.find
- str.index
- str.rfind
- str.rindex
This commit is contained in:
Erlend E. Aasland 2024-04-03 17:59:18 +02:00 committed by GitHub
parent 345194de8c
commit 7ecd55d604
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 444 additions and 222 deletions

View file

@ -1503,15 +1503,15 @@ class StringLikeTest(BaseTest):
# issue 11828
s = 'hello'
x = 'x'
self.assertRaisesRegex(TypeError, r'^find\(', s.find,
self.assertRaisesRegex(TypeError, r'^find\b', s.find,
x, None, None, None)
self.assertRaisesRegex(TypeError, r'^rfind\(', s.rfind,
self.assertRaisesRegex(TypeError, r'^rfind\b', s.rfind,
x, None, None, None)
self.assertRaisesRegex(TypeError, r'^index\(', s.index,
self.assertRaisesRegex(TypeError, r'^index\b', s.index,
x, None, None, None)
self.assertRaisesRegex(TypeError, r'^rindex\(', s.rindex,
self.assertRaisesRegex(TypeError, r'^rindex\b', s.rindex,
x, None, None, None)
self.assertRaisesRegex(TypeError, r'^count\(', s.count,
self.assertRaisesRegex(TypeError, r'^count\b', s.count,
x, None, None, None)
self.assertRaisesRegex(TypeError, r'^startswith\b', s.startswith,
x, None, None, None)