-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Change in AbstractArray
promotion
#45511
Comments
Related: #44939, which is technically a breakage if the promotion rules aren't already defined. |
Duplicate of #44821 |
This promotion rule is valid only if all |
Something to note is that we don't define promotion rules for other container types. For example: julia> [Dict(1=>2), Dict(1.0=>2.0)]
2-element Vector{Dict}:
Dict(1 => 2)
Dict(1.0 => 2.0) |
Triage agrees that this change was bad and should not have happened (although we probably explicitly said it was good at the time) |
Here is another example:
|
A related issue of discrepancy between a comprehension and array literal (and Julia manual promises here they work in the same way):
|
#44096 changed promotion rules for
AbstractArray
objects. In current Julia releases and 1.8,[A, B]
preserves the type of arraysA
andB
. In current master, arrays are promoted to a common type if their types differ. This can give surprising results, as it seems relatively common (#44096 (comment)) to test different array types using loops such as:which now only tests
Vector{Int}
on three identical arrays.Maybe this will mainly affect tests, as this kind of pattern is unlikely to be used in implementations. But it's somewhat pernicious as it doesn't make tests fail, but instead silently reduces test coverage. If it happens in real code, promotion can lead to allocating a copy of the inputs, which could dramatically increase memory usage (at the benefit of type stability), in particular if some of the inputs are sparse but one of them is dense.
This change doesn't seem to have been discussed, but it was raised recently on Slack so I figured it would be worth going through triage to ensure this is what we want before releasing 1.8.
Cc: @vtjnash, @KristofferC, @fredrikekre, @mbauman
The text was updated successfully, but these errors were encountered: