-
Notifications
You must be signed in to change notification settings - Fork 10
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
Iterable as a second argument #15
Comments
Yes, just use a helper function:
There is also https://docs.python.org/3.6/library/functools.html#functools.partial If you have a suggestion for an alternative API, feel free to suggest it. |
I was thinking that maybe map can assign the iterable to y because the
value of x was given explicitly. Similarly, starmap could assign iterables
to the subsequent arguments that were not explicitly provided in **kwargs.
…On 16 March 2018 at 19:46, Sergio Oller ***@***.***> wrote:
Yes, just use a helper function:
def g(y, x):
return f(x, y)
parmap.map(g, range(100), x=1)
There is also https://docs.python.org/3.6/library/functools.html#
functools.partial
If you have a suggestion for an alternative API, feel free to suggest it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEuSHZ9syigC7E8FPBc3IJI6w4TxzP5Wks5tfAhtgaJpZM4St3tA>
.
|
I have some concerns with that approach: There is a use case where an extra argument is an iterable:
It would be harder (impossible) in this case for parmap to guess that the iterable argument is the second one. It is then possible to modify
Here with your API proposal, the first call would work as expected, the second one would not do what we wanted. It could surprise parmap users. For an interactive use (such as in a notebook) the approach you suggest is good, in most cases it will do what we want and we will like it. However, parmap users may start to use that syntax in their python packages, and their users may use those packages in surprising ways that can lead to parmap iterating in the wrong argument. https://en.m.wikipedia.org/wiki/Principle_of_least_astonishment Besides, by reading at your first example I could also think that you wanted to compute What would you think of an API like:
? |
My idea was that parmap.map(times2, xlimits = [0, 5], x = range(10)) should simply call times2 with the given arguments but parmap.map(times2, range(10), xlimits = [0, 5])
parmap.map(times2, iterable=range(10), xlimits = [0, 5]) could call times2 with different values of x. At the same time, I like
It is nicely explicit. |
It is possible to easily achieve something like:
?
The text was updated successfully, but these errors were encountered: