Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions newsfragments/4981.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `is_type_of` for native types not using same specialized check as `is_type_of_bound`.
2 changes: 1 addition & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ macro_rules! pyobject_native_type_info(

$(
#[inline]
fn is_type_of_bound(obj: &$crate::Bound<'_, $crate::PyAny>) -> bool {
fn is_type_of(obj: &$crate::Bound<'_, $crate::PyAny>) -> bool {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The point here being that is_type_of_bound is defaulted to just call is_type_of. is_type_of has a generic default which calls PyObject_TypeCheck instead of more specific (faster) functions like PyList_Check.

#[allow(unused_unsafe)]
unsafe { $checkfunction(obj.as_ptr()) > 0 }
}
Expand Down
Loading