**Deprecation**: clib.Session.virtualfile_from_vectors now takes only one argument #3522
+61
−27
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.
This is a POC PR.
In the
Session.virtualfile_in
method, we must prepare for_data
that will be passed to differentvirtualfile_from_*
methods. Currently,_data
must be an iterable (e.g.,_data = (data, )
even for the simplest case) and when pass it to_virtualfile_from
, we need to unpack it like:The complexity is because, while most
_virtualfile_from_*
methods only take a single argument, the_virtualfile_from_vectors
takes multiple arguments. The_virtualfile_from_vectors
is defined like_virtualfile_from_vectors(*vectors)
and must be called like_virtualfile_from_vectors(x, y, z)
.This PR changes its definition to
_virtualfile_from_vectors(vectors)
, and now it should be called like_virtualfile_from_vectors((x, y, z))
.With this breaking change, thevirtualfile_in
function can be simplified slightly, which I think is more readable. Then the question is, is it worth a breaking change?Edit: Actually it's possible to introduce the new syntax without breaking backward compatibility. This is done in f5b0e8e.