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
proposal: slices: add Zip function #65062
Comments
how useful is this when all slices have to be of the same type? |
@seankhliao The first thing that comes to my mind is machine learning and, to be more precise, tensor processing. In this context, data must be normalized. Std lib lacks the capabilities for that field; maybe this function could fit better under some newly formed package. |
I've seen this coming up as part of the Go iterator activities. Seeing the Python implementation working on iterators I wonder if this would be better move to the Go iterator field? |
Interesting point @thediveo. I don't know the overall direction or whether the community want |
I agree that this function should wait till the question of generalized sequences and iterators is settled. BTW: it might be slightly faster (and better locality) to make a single allocation a slice of m*n elements upfront, and then break off pieces (setting the cap each time) for the individual rows of the result (like this). |
Proposal Details
Proposal Details
I propose to add the
Zip
function to theslices
package. The zip function is a critical part of the Python toolkit in the context of data science and machine learning.Zip
can be considered a supper set of transpose but is less restrictive regarding input shape. Silently adjusting output on a best-effort basis.Example
Implementation
Edit: The allocation pattern changed as suggested by @adonovan
Test
Benchmark
The text was updated successfully, but these errors were encountered: