Repository navigation
gh-162350: Add AC vectorcall for itertools - #162590
Conversation
cmaloney
left a comment
There was a problem hiding this comment.
Can we split this into smaller more reviewable pieces. The just add @vectorcall can all be one PR / that just depends on codegen being right + the implementations being sure they take strong references generally.
For the ones adding signatures I'm okay with 2-3 in a single PR but try to keep them small / related cases. For all of them the more we can make things line up between here and the docs so inspect.signature gives the right thing the better. Not everything is supported in AC but can always use @text_signature to override.
| @vectorcall | ||
| @classmethod | ||
| itertools.islice.__new__ as islice_new | ||
| iterable: object |
There was a problem hiding this comment.
could we more closelkly match the docs names for the parameters? (esp. since this makes the signature visible): https://docs.python.org/3/library/itertools.html#itertools.islice
| PyTypeObject *chain_type = state->chain_type; | ||
| if ((type == chain_type || type->tp_init == chain_type->tp_init) && | ||
| !_PyArg_NoKeywords("chain", kwds)) | ||
| PyObject *source = PyTuple_FromArray(iterables, iterables_length); |
There was a problem hiding this comment.
for cases like this where we always are going to need a tuple other converters are likely more efficient. It may actually be a case to avoid Vectorcall as we will always end up constructing a tuple anyways so avoiding one in the call doesn't help a lot.
| [clinic start generated code]*/ | ||
|
|
||
| static PyObject * | ||
| itertools__tee_impl(PyTypeObject *type, PyObject *iterable) |
There was a problem hiding this comment.
nit: this one isn't actually used in the a common construction path tee is implemented by itertools_tee_impl which ends up calling teedataobject_newinternal rather than this. That means this is just adding code / binary size without providing benefit.
|
That looks good! Should have it all reviewed by Monday (holiday weekend here). |
Add
@vectorcallto existing AC.Benchmark:
Details