Skip to content

Commit

Permalink
default uses PyObject_Vectorcall()
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Jul 7, 2023
1 parent 26c93c6 commit 1953ecf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/serialize/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,21 @@ impl Serialize for DefaultSerializer {
if unlikely!(self.default_calls == RECURSION_LIMIT) {
err!(SerializeError::DefaultRecursionLimit)
}
#[cfg(not(Py_3_10))]
let default_obj = ffi!(PyObject_CallFunctionObjArgs(
callable.as_ptr(),
self.ptr,
std::ptr::null_mut() as *mut pyo3_ffi::PyObject
));
#[cfg(Py_3_10)]
let default_obj = unsafe {
pyo3_ffi::PyObject_Vectorcall(
callable.as_ptr(),
std::ptr::addr_of!(self.ptr),
pyo3_ffi::PyVectorcall_NARGS(1) as usize,
std::ptr::null_mut() as *mut pyo3_ffi::PyObject,
)
};
if unlikely!(default_obj.is_null()) {
err!(SerializeError::UnsupportedType(nonnull!(self.ptr)))
} else {
Expand Down

0 comments on commit 1953ecf

Please sign in to comment.