8000 gh-90370: avoid temporary tuple creation for vararg in AC by skirpichev · Pull Request #126064 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-90370: avoid temporary tuple creation for vararg in AC #126064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 31, 2024
Prev Previous commit
Next Next commit
address review: has_varag_hack -> pass_vararg_directly
  • Loading branch information
skirpichev committed Oct 28, 2024
commit 42c977a6af6e9063dbb1e3681042c19b2c3329a3
9 changes: 5 additions & 4 deletions Tools/clinic/libclinic/clanguage.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,9 @@ def render_function(
requires_defining_class = (len(selfless)
and isinstance(selfless[0].converter,
defining_class_converter))
has_varag_hack = all(p.is_positional_only() or p.is_vararg()
for p in selfless) and not requires_defining_class
pass_vararg_directly = (all(p.is_positional_only() or p.is_vararg()
for p in selfless)
and not requires_defining_class)

# offset i by -1 because first_optional needs to ignore self
for i, p in enumerate(parameters, -1):
Expand All @@ -409,7 +410,7 @@ def render_function(
if (i != -1) and (p.default is not unspecified):
first_optional = min(first_optional, i)

if p.is_vararg() and not has_varag_hack:
if p.is_vararg() and not pass_vararg_directly:
data.cleanup.append(f"Py_XDECREF({c.parser_name});")

# insert group variable
Expand All @@ -423,7 +424,7 @@ def render_function(
data.impl_parameters.append("int " + group_name)
has_option_groups = True

if p.is_vararg() and has_varag_hack:
if p.is_vararg() and pass_vararg_directly:
data.impl_arguments.append('nvararg')
data.impl_parameters.append('Py_ssize_t nargs')
p.converter.type = 'PyObject *const *'
Expand Down
Loading
0