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

Make broadcast return BitArray even if it cannot be inferred #19854

Merged
merged 2 commits into from
Jan 5, 2017

Conversation

martinholters
Copy link
Member

Thanks to #17623 broadcast returns BitArray instead of Array{Bool} if this can be decided based on inference:

julia> foo(x::Bool) = (x,"bla")[1] # can be inferred
foo (generic function with 1 method)

julia> foo.(trues(2))
2-element BitArray{1}:
 true
 true

julia> bar(x::Bool) = (x,"bla")[length([x])] # cannot be inferred
bar (generic function with 1 method)

julia> bar.(trues(2))
2-element Array{Bool,1}:
 true
 true

Reliance on inference should be avoided, so with this PR:

julia> bar.(trues(2))
2-element BitArray{1}:
 true
 true

a = f.([false])
@test a isa Array{String}
@test a == ["false"]
a = f.([true, false])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could just check that f.([true, false]) == [true, "false"] here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Update coming...

@martinholters
Copy link
Member Author

Better be sure, so @nanosoldier runbenchmarks(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

@martinholters
Copy link
Member Author

The single benchmark regression is likely noise; broadcast is used so ubiquitously nowadays, a real regressions would likely have affected many more benchmarks.
Good to go?

@stevengj stevengj merged commit b53cd8b into master Jan 5, 2017
@stevengj stevengj deleted the mh/broadcast_bitarray branch January 5, 2017 16:19
@nalimilan
Copy link
Member

BTW, shouldn't map also return a BitArray in the same cases as broadcast?

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

Successfully merging this pull request may close these issues.

5 participants