Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TYP: fix and improve numpy.lib._utils_impl #29181

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged

Conversation

jorenham
Copy link
Member

@jorenham jorenham commented Jun 11, 2025

ported from numpy/numtype#170


this resolves some red squigglies in e.g.

if dtype.names is not None:
# This is a record array. The .descr is fine. XXX: parts of the
# record array with an empty name, like padding bytes, still get
# fiddled with. This needs to be fixed in the C implementation of
# dtype().
return dtype.descr
elif not type(dtype)._legacy:
# this must be a user-defined dtype since numpy does not yet expose any
# non-legacy dtypes in the public API
#
# non-legacy dtypes don't yet have __array_interface__
# support. Instead, as a hack, we use pickle to save the array, and lie
# that the dtype is object. When the array is loaded, the descriptor is
# unpickled with the array and the object dtype in the header is
# discarded.
#
# a future NEP should define a way to serialize user-defined
# descriptors and ideally work out the possible security implications
warnings.warn("Custom dtypes are saved as python objects using the "
"pickle protocol. Loading this file requires "
"allow_pickle=True to be set.",
UserWarning, stacklevel=2)
return "|O"
else:
return dtype.str

@jorenham jorenham added 41 - Static typing numtype Isssue/PR related to numpy/numtype labels Jun 11, 2025
@charris charris merged commit ceb858f into numpy:main Jun 11, 2025
77 checks passed
@charris
Copy link
Member

charris commented Jun 11, 2025

Thanks Joren.

@jorenham jorenham deleted the numtype/170 branch June 11, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
41 - Static typing numtype Isssue/PR related to numpy/numtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants