gh-87613: Argument Clinic vectorcall decorator (GH-145381) · python/cpython@86b55a6 · GitHub
Skip to content

Commit 86b55a6

Browse files
authored
gh-87613: Argument Clinic vectorcall decorator (GH-145381)
Add `@vectorcall` as a decorator to Argument Clinic (AC) which generates a new [Vectorcall Protocol](https://docs.python.org/3/c-api/call.html#the-vectorcall-protocol) argument parsing C function named `{}_vectorcall`. This is only supported for `__new__` and `__init__` currently to simplify implementation. The generated code has similar or better performance to existing hand-written cases for `list`, `float`, `str`, `tuple`, `enumerate`, `reversed`, and `int`. Using the decorator added vectorcall to `bytearray` and construction got 1.09x faster. For more details see the comments in gh-87613.
1 parent 9bd670c commit 86b55a6

18 files changed

Lines changed: 1310 additions & 198 deletions

Lib/test/test_clinic.py

Lines changed: 207 additions & 0 deletions

Lib/test/test_tuple.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def test_constructors(self):
3838
self.assertEqual(tuple(x for x in range(10) if x % 2),
3939
(1, 3, 5, 7, 9))
4040

41+
def test_too_many_args(self):
42+
with self.assertRaises(TypeError):
43+
tuple([1, 2], 3)
44+
4145
def test_keyword_args(self):
4246
with self.assertRaisesRegex(TypeError, 'keyword argument'):
4347
tuple(sequence=())
Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)