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

gh-91049: Introduce set vectorcall field API for PyFunctionObject#92257

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
26 commits
Select commitHold shift + click to select a range
9cf96ec
Enable setting vectorcall field on PyFunctionObjects
May 3, 2022
282e3dc
check if vectorcall is nondefault before inlining call
May 3, 2022
edcdcf1
📜🤖 Added by blurb_it.
blurb-it[bot]May 3, 2022
debf5a9
Apply suggestions from code review
adphrostMay 3, 2022
473d18d
addressed comments
May 3, 2022
76e8c9d
added to docs
May 3, 2022
3337459
Merge branch 'main' into pyfunctionobject-set-vectorcall-field
Jun 16, 2022
1543f44
updated doc with fix by itamaro
Jun 16, 2022
08082bd
formatting
Jun 16, 2022
ed93327
removed doc from 3.11
Jun 16, 2022
24ffd30
remove lines from 3.11
Jun 16, 2022
89cb4b2
Apply review feedback from vstinner and markshannon
itamaroJun 21, 2022
3387d4a
Merge branch 'main' into gh-91049-set-vectorcall
itamaroSep 2, 2022
b0cc28a
Merge branch 'main' into gh-91049-set-vectorcall
itamaroSep 5, 2022
99e4085
Add deopt on func version in LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN
itamaroSep 6, 2022
24353c8
write func version to cache keys version when specializing LOAD_ATTR_…
itamaroSep 6, 2022
60f7769
remove redundant argcount check in LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN …
itamaroSep 6, 2022
376ee75
Add missing periods in docs
itamaroSep 6, 2022
56ffc70
move warning comment to the function C API docs
itamaroSep 6, 2022
5340e87
Merge branch 'main' into pyfunctionobject-set-vectorcall-field
itamaroSep 6, 2022
a5e9d13
fix race with GH-96519 (removed func_version in LOAD_ATTR_GETATTRIBUT…
itamaroSep 6, 2022
12faf52
PEP-7 formatting
itamaroSep 7, 2022
6623470
Address review feedback
itamaroSep 7, 2022
9149f14
Add test for LOAD_ATTR specialization when overriding vectorcall of _…
itamaroSep 8, 2022
e732d7e
Improve setvectorcall + specialization testing
itamaroSep 8, 2022
84874fb
Merge branch 'main' into pyfunctionobject-set-vectorcall-field
itamaroSep 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Apply review feedback from vstinner and markshannon
  • Loading branch information
@itamaro
itamaro authored andAndrew Frost committedJun 22, 2022
commit89cb4b25271be5a0e5dd7b18e464e3dc72d4195a
1 change: 1 addition & 0 deletionsDoc/c-api/function.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,6 +87,7 @@ There are a few functions specific to Python functions.

Set the vectorcall field of a given function object *func*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Set the vectorcall field of a given function object *func*
Set the vectorcall field of a given function object *func*.


.. versionadded:: 3.12

.. c:function:: PyObject* PyFunction_GetClosure(PyObject *op)

Expand Down
4 changes: 3 additions & 1 deletionDoc/whatsnew/3.12.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -237,7 +237,9 @@ New Features
(Contributed by Wenzel Jakob in :gh:`93012`.)

* Add new function :c:func:`PyFunction_SetVectorcall` to the C API
which sets the vectorcall field of a given PyFunctionObject
which sets the vectorcall field of a given :c:type:`PyFunctionObject`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
which sets the vectorcall field of a given:c:type:`PyFunctionObject`
which sets the vectorcall field of a given:c:type:`PyFunctionObject`.

Warning: extensions using this API must preserve the behavior
of the unaltered function!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't think that this document is the right place to put a warning. Why this warning is not in the documentation of the function?

(Contributed by Andrew Frost in :gh:`92257`.)

Porting to Python 3.12
Expand Down
2 changes: 1 addition & 1 deletionLib/test/test_call.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -673,7 +673,7 @@ def f(num): return num + 1
function_setvectorcall(f)
# make sure specializer is triggered by running > 50 times
for _ in range(51):
self.assertIsNone(f(num))
self.assertEqual("overridden",f(num))

class A:
def method_two_args(self, x, y):
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
CPython extensions providing optimized execution of Python bytecode (like Cinder JIT and Pyjion)
can benefit from being able to modifythe vectorcall fieldon instancesofPyFunctionObject to allow calling the optimized path (e.g. JIT-compiled) directly.
Add new function :c:func:`PyFunction_SetVectorcall` to the C API
which setsthe vectorcall field ofa given :c:type:`PyFunctionObject`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
which sets the vectorcall field of a given:c:type:`PyFunctionObject`
which sets the vectorcall field of a given:c:type:`PyFunctionObject`.


This PR introduces an API call where vectorcall field can be modified like so:

`void PyFunction_SetVectorcall(PyFunctionObject *func, vectorcallfunc vectorcall);`
Warning: extensions using this API must preserve the behavior
of the unaltered function!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please remove this warning.

2 changes: 1 addition & 1 deletionModules/_testcapimodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5359,7 +5359,7 @@ test_pyobject_vectorcall(PyObject *self, PyObject *args)
static PyObject *
override_vectorcall(
PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames) {
Py_RETURN_NONE;
return PyUnicode_FromString("overridden");
}

static PyObject *
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp