Skip to content

BUG: Allow pickling all relevant DType types/classes#18345

Merged
charris merged 1 commit intonumpy:maintenance/1.20.xfrom
charris:backport-18332
Feb 6, 2021
Merged

BUG: Allow pickling all relevant DType types/classes#18345
charris merged 1 commit intonumpy:maintenance/1.20.xfrom
charris:backport-18332

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Feb 6, 2021

Backport of #18332.

Introducing the metaclass without a canonical top-level name broke
pickling of type(np.dtype(...)) (which was always just np.dtype).

While a better solution will likely be possible by making the
DTypes HeapTypes and this solution may not work for all imaginable
cases (i.e. it is plausible for a dtype to not have a scalar type
associated), using a copyreg registration for the metaclass
surprisingly works without any issues and seems like the simplest
solution right now.

Closes gh-16692, gh-18325

Introducing the metaclass without a canonical top-level name broke
pickling of `type(np.dtype(...))` (which was always just `np.dtype`).

While a better solution will likely be possible by making the
DTypes HeapTypes and this solution may not work for all imaginable
cases (i.e. it is plausible for a dtype to not have a scalar type
associated), using a `copyreg` registration for the metaclass
surprisingly works without any issues and seems like the simplest
solution right now.

Closes numpygh-16692, numpygh-18325
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants