Skip to content
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

Cast dict to mapping and list to sequence, transferring ownership #3981

Closed
davidhewitt opened this issue Mar 22, 2024 · 0 comments · Fixed by #3982
Closed

Cast dict to mapping and list to sequence, transferring ownership #3981

davidhewitt opened this issue Mar 22, 2024 · 0 comments · Fixed by #3982

Comments

@davidhewitt
Copy link
Member

We have PyDict::as_mapping, PyList::as_sequence, and PyTuple::as_sequence.

With the new Bound API, ownership matters, so we might want to add versions of these methods which transfer ownership.

  • PyDict::into_mapping
  • PyList::into_sequence
  • PyTuple::as_sequence

maybe?

(The equivalent alternative at the moment is to use the unsafe .downcast_into_unchecked::<Mapping>() etc, but that also runs up against the friction observed with deref & ownership in #3980)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant