We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cc768a6 commit f0330aaCopy full SHA for f0330aa
pandas/core/dtypes/astype.py
@@ -257,6 +257,11 @@ def astype_is_view(dtype: DtypeObj, new_dtype: DtypeObj) -> bool:
257
-------
258
True if new data is a view or not guaranteed to be a copy, False otherwise
259
"""
260
+ if dtype.kind in "iufb" and dtype.kind == new_dtype.kind:
261
+ # fastpath for numeric dtypes
262
+ if hasattr(dtype, "itemsize") and hasattr(new_dtype, "itemsize"):
263
+ return dtype.itemsize == new_dtype.itemsize # pyright: ignore[reportAttributeAccessIssue]
264
+
265
if isinstance(dtype, np.dtype) and not isinstance(new_dtype, np.dtype):
266
new_dtype, dtype = dtype, new_dtype
267
0 commit comments