Draft
Conversation
|
FYI, i made some work about unpacking of *args and **kwargs here Once used, this gives some performance gains (see Performance Improvements Details section), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per #5623, an implementation of Rust-side unpacking of Python objects.
This is a draft PR, because the API turned out to be trickier than I thought it would be. We have two types: the source (Python object) and the destination (the Rust type). The current trait is only generic over the destination:
The problem with this approach, as I discovered while writing the tests, is that calling it becomes a mouthful:
Which means that ideally the trait should also be generic over the python type. This is also important because different types have different error messages. Arbitrary iterators (thanks to OutSquareCapital, I didn't know they unpackable) don't specify how many items we got because they are pulled lazily:
And sequences with a defined length do:
It might make sense to define the trait as
Unpackable<T>where the implementer is the source andTis the destination. But that'd mean there would be n x m implementations (for 12 tuples forPySequence,PyAny, andPyIterator), which might lead to bloat.