Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2efdd2a

Browse files
authored
gh-106023: Remove _PyObject_FastCall() function (#106265)
1 parent0b51463 commit2efdd2a

File tree

7 files changed

+13
-51
lines changed

7 files changed

+13
-51
lines changed

‎Doc/whatsnew/3.13.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,8 @@ Removed
597597

598598
Just remove the underscore prefix to update your code.
599599
(Contributed by Victor Stinner in:gh:`106084`.)
600+
601+
* Remove private ``_PyObject_FastCall()`` function:
602+
use ``PyObject_Vectorcall()`` which is available since Python 3.8
603+
(:pep:`590`).
604+
(Contributed by Victor Stinner in:gh:`106023`.)

‎Include/cpython/abstract.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ PyAPI_FUNC(PyObject *) PyObject_VectorcallDict(
2424
size_tnargsf,
2525
PyObject*kwargs);
2626

27-
// Same as PyObject_Vectorcall(), except without keyword arguments
28-
PyAPI_FUNC(PyObject*)_PyObject_FastCall(
29-
PyObject*func,
30-
PyObject*const*args,
31-
Py_ssize_tnargs);
32-
3327
PyAPI_FUNC(PyObject*)PyObject_CallOneArg(PyObject*func,PyObject*arg);
3428

3529
staticinlinePyObject*

‎Lib/test/test_call.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -519,19 +519,6 @@ def check_result(self, result, expected):
519519
expected= (*expected[:-1],result[-1])
520520
self.assertEqual(result,expected)
521521

522-
deftest_fastcall(self):
523-
# Test _PyObject_FastCall()
524-
525-
forfunc,args,expectedinself.CALLS_POSARGS:
526-
withself.subTest(func=func,args=args):
527-
result=_testcapi.pyobject_fastcall(func,args)
528-
self.check_result(result,expected)
529-
530-
ifnotargs:
531-
# args=NULL, nargs=0
532-
result=_testcapi.pyobject_fastcall(func,None)
533-
self.check_result(result,expected)
534-
535522
deftest_vectorcall_dict(self):
536523
# Test PyObject_VectorcallDict()
537524

@@ -945,11 +932,11 @@ def py_recurse(n, m):
945932

946933
defc_recurse(n):
947934
ifn:
948-
_testcapi.pyobject_fastcall(c_recurse, (n-1,))
935+
_testcapi.pyobject_vectorcall(c_recurse, (n-1,), ())
949936

950937
defc_py_recurse(m):
951938
ifm:
952-
_testcapi.pyobject_fastcall(py_recurse, (1000,m))
939+
_testcapi.pyobject_vectorcall(py_recurse, (1000,m), ())
953940

954941
depth=sys.getrecursionlimit()
955942
sys.setrecursionlimit(100_000)

‎Lib/test/test_gdb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,13 +729,13 @@ def test_two_abs_args(self):
729729

730730
SAMPLE_WITH_C_CALL="""
731731
732-
from _testcapi importpyobject_fastcall
732+
from _testcapi importpyobject_vectorcall
733733
734734
def foo(a, b, c):
735735
bar(a, b, c)
736736
737737
def bar(a, b, c):
738-
pyobject_fastcall(baz, (a, b, c))
738+
pyobject_vectorcall(baz, (a, b, c), None)
739739
740740
def baz(*args):
741741
id(42)
@@ -756,7 +756,7 @@ def test_pyup_command(self):
756756
self.assertMultilineMatches(bt,
757757
r'''^.*
758758
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
759-
#[0-9]+ <built-in methodpyobject_fastcall of module object at remote 0x[0-9a-f]+>
759+
#[0-9]+ <built-in methodpyobject_vectorcall of module object at remote 0x[0-9a-f]+>
760760
$''')
761761

762762
@unittest.skipUnless(HAS_PYUP_PYDOWN,"test requires py-up/py-down commands")
@@ -785,7 +785,7 @@ def test_up_then_down(self):
785785
self.assertMultilineMatches(bt,
786786
r'''^.*
787787
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
788-
#[0-9]+ <built-in methodpyobject_fastcall of module object at remote 0x[0-9a-f]+>
788+
#[0-9]+ <built-in methodpyobject_vectorcall of module object at remote 0x[0-9a-f]+>
789789
#[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
790790
$''')
791791

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove private ``_PyObject_FastCall()`` function: use ``PyObject_Vectorcall()``
2+
which is available since Python 3.8 (:pep:`590`). Patch by Victor Stinner.

‎Modules/_testcapi/vectorcall.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,6 @@ fastcall_args(PyObject *args, PyObject ***stack, Py_ssize_t *nargs)
2626
}
2727

2828

29-
staticPyObject*
30-
test_pyobject_fastcall(PyObject*self,PyObject*args)
31-
{
32-
PyObject*func,*func_args;
33-
PyObject**stack;
34-
Py_ssize_tnargs;
35-
36-
if (!PyArg_ParseTuple(args,"OO",&func,&func_args)) {
37-
returnNULL;
38-
}
39-
40-
if (fastcall_args(func_args,&stack,&nargs)<0) {
41-
returnNULL;
42-
}
43-
return_PyObject_FastCall(func,stack,nargs);
44-
}
45-
4629
staticPyObject*
4730
test_pyobject_fastcalldict(PyObject*self,PyObject*args)
4831
{
@@ -259,7 +242,6 @@ _testcapi_has_vectorcall_flag_impl(PyObject *module, PyTypeObject *type)
259242
}
260243

261244
staticPyMethodDefTestMethods[]= {
262-
{"pyobject_fastcall",test_pyobject_fastcall,METH_VARARGS},
263245
{"pyobject_fastcalldict",test_pyobject_fastcalldict,METH_VARARGS},
264246
{"pyobject_vectorcall",test_pyobject_vectorcall,METH_VARARGS},
265247
{"function_setvectorcall",function_setvectorcall,METH_O},

‎Objects/call.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,6 @@ PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
327327
}
328328

329329

330-
PyObject*
331-
_PyObject_FastCall(PyObject*func,PyObject*const*args,Py_ssize_tnargs)
332-
{
333-
PyThreadState*tstate=_PyThreadState_GET();
334-
return_PyObject_FastCallTstate(tstate,func,args,nargs);
335-
}
336-
337-
338330
PyObject*
339331
_PyObject_Call(PyThreadState*tstate,PyObject*callable,
340332
PyObject*args,PyObject*kwargs)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp