Skip to content
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

map(Function, AbstractArray) and siblings use type of first output to determine type of all output #2938

Closed
WestleyArgentum opened this issue Apr 25, 2013 · 2 comments

Comments

@WestleyArgentum
Copy link
Member

It seems that some effort was put into implementing map this way, so I figured I should post before putting time towards a pull request.

I'm assuming the reason for this is speed. I'd be interested to know, has anyone has profiled it done this way vs producing Any arrays?

I think it seems unlikely at first that the function you pass into map will return values of different types... but this has come up a couple times with strings for me. If the first string I output is plain ascii and then the second is utf8, I'm hosed.

ex:

julia> d = { "a" => "ascii", "u" => "u†f∞" }
{"u"=>"u†f∞","a"=>"ascii"}

julia> map((a)->d[a], ["a", "u"])
ERROR: invalid ASCII sequence

Maybe the case for strings can be special cased, or maybe map should just produce Any arrays.

@mlubin
Copy link
Member

mlubin commented Apr 25, 2013

dup of #210 (old issue)

@WestleyArgentum
Copy link
Member Author

Ah, you're right, and I think Stephan's comment in #670 really sums it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants