Skip to content

call_method(): call _PyObject_FastCall() rather than _PyObject_VaCallFunctionObjArgs() #73419

Closed

Description

@vstinner
BPO 29233
Nosy @vstinner, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2017-01-11.00:26:53.162>
created_at = <Date 2017-01-10.23:05:00.633>
labels = ['interpreter-core', '3.7', 'performance']
title = 'call_method(): call _PyObject_FastCall() rather than _PyObject_VaCallFunctionObjArgs()'
updated_at = <Date 2017-01-11.00:26:53.161>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2017-01-11.00:26:53.161>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2017-01-11.00:26:53.162>
closer = 'vstinner'
components = ['Interpreter Core']
creation = <Date 2017-01-10.23:05:00.633>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 29233
keywords = []
message_count = 3.0
messages = ['285165', '285166', '285167']
nosy_count = 3.0
nosy_names = ['vstinner', 'python-dev', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'performance'
url = 'https://bugs.python.org/issue29233'
versions = ['Python 3.7']

Activity

  1. vstinner commented on Jan 10, 2017

    @vstinner
    MemberAuthor

    Recently, I modified call_method() and call_maybe() of Objects/typeobject.c to avoid the creation of a temporary tuple: replace Py_VaBuildValue()+PyObject_Call() with the new _PyObject_VaCallFunctionObjArgs().

    But while working on the issue bpo-28870, I noticed that _PyObject_VaCallFunctionObjArgs() is not efficient and can be avoided. In typeobject.c, the number of arguments is hardcoded, so we don't need complex functions to compute the number of arguments and decide to allocate an array on the stack or on the heap.

  2. python-dev commented on Jan 10, 2017

    python-devmannequin
    Mannequin

    New changeset b9404639a18c by Victor Stinner in branch 'default':
    call_method() now uses _PyObject_FastCall()
    https://hg.python.org/cpython/rev/b9404639a18c

  3. vstinner commented on Jan 10, 2017

    @vstinner
    MemberAuthor

    Full commit message:

    changeset: 106081:b9404639a18c
    tag: tip
    user: Victor Stinner <[email protected]>
    date: Wed Jan 11 00:07:40 2017 +0100
    files: Include/abstract.h Objects/abstract.c Objects/typeobject.c
    description:
    call_method() now uses _PyObject_FastCall()

    Issue bpo-29233: Replace the inefficient _PyObject_VaCallFunctionObjArgs() with
    _PyObject_FastCall() in call_method() and call_maybe().

    Only a few functions call call_method() and call it with a fixed number of
    arguments. Avoid the complex and expensive _PyObject_VaCallFunctionObjArgs()
    function, replace it with an array allocated on the stack with the exact number
    of argumlents.

    It reduces the stack consumption, bytes per call, before => after:

    test_python_call: 1168 => 1152 (-16 B)
    test_python_getitem: 1344 => 1008 (-336 B)
    test_python_iterator: 1568 => 1232 (-336 B)

    Remove the _PyObject_VaCallFunctionObjArgs() function which became useless.
    Rename it to object_vacall() and make it private.

  4. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usage

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions