-
Notifications
You must be signed in to change notification settings - Fork 91
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
Supporting map
and friends
#31
Comments
I'm hesitant to get into the business of overriding certain functions like this, but that is just my opinion and @timholy may differ. That said, maybe there could be a convenience function that takes |
I did think it seemed weird to be rewriting the function argument |
For the time being, I agree with @garrison, although as you say that may change with fast closures. Eliminating that performance bottleneck will, I suspect, have pretty dramatic (and to me somewhat unpredictable) consequences for how people write julia code. |
I haven't been paying close attention lately; do you have a link to progress on this front? I agree with @timholy that this could have dramatic consequences for how people write Julia code. |
I am, in principle, very much for the idea of supporting I have no arguments against re-writing or wrapping the user-provided function That said, if there was a PR for this functionality (with tests), I wouldn't hesitate to hit "merge" the same day a Julia version with fast anonymous functions is released. |
It depends on the use case too: the extra cost of the anonymous function will hardly matter if you are using this to track an iteration over a few big blocks of work rather than many small ones. Anyway, I have been looking for an excuse to learn how to write macros, so I think I might give this a crack :) |
I should have been more clear before, but what I do not like about this is that the macro is then responsible for recognizing certain functions like progressmap(f, itr) |
Does the macro see the individual methods, or just the name "map"? If the latter, wouldn't it work anyway - provided only that the particular method being called adheres to the (f, itr) argument order? If we wrote a separate progressmap function, could you then have @showprogress map(args...) expand to progressmap(args...) or is that running into the same problems? Mostly I ask because the macro form is very friendly, similar to |
The macro really just sees the symbol |
All of them, with one single exception, could be formulated as I understand that as a deeply, if only conventionally, rooted contract of the |
It's much more complicated than that. Check base for the source code for the implementation of map; it deals with empty containers, poorly-typed containers, functions that are type-unstable, etc. and yet return a container with sensible type. |
Git etiquette question: I am putting together a pull request to try using |
Hard to say. I would make it a separate commit but keep it in the same pull request for now. It can always be made its own pull request later if it seems like a reasonable contribution and the second commit is not. (If instead you make the refactor its own pull request, you'll be forced to wait on it being merged before you can submit the second. I guess you could always make a pull request to the branch on which you are working, but that sounds complicated.) |
(@garrison As long as there's two commits, there can be two PR's, and one doesn't have to be merged for the other to be filed. What would happen, though, is that before the first one is merged, the second one would appear to contain commits from both of them. Starting to derail here...) @swt30 As @garrison says, the best option is to create a branch with the refactor and the |
@timholy what's the best way for me to monitor progress for a map? Do I want to be re-casting it as a |
Can't you just manually do the rewrite as proposed above? |
@martinholters I could. I was concerned about the possible performance issues highlighted that then seem to get resolved here but I should have just tried it first to see whether it slows down my code significantly. |
Working on this in #108 |
Is supporting |
I don't know of anyone working on it now. |
Any chance of implementing this feature? |
I don't have any experience writing macros yet, but is it possible to let
@showprogress
support functions likemap
(andforeach
, which has recently been added to Julia master)? I guess you could rewriteas something like
although I don't know if you need extra precautions in case
itr
doesn't have a length defined for whatever reason.The text was updated successfully, but these errors were encountered: