-
-
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
deprecate fallback constructor #23273
Conversation
base/int.jl
Outdated
throw_inexacterror(f::Symbol, ::Type{T}, val) where T = | ||
(@_noinline_meta; throw(InexactError(f, T, val))) | ||
# calls constructors defined in boot.jl | ||
convert(T::BitIntegerType, x::Union{BitInteger, Bool}) = T(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in abstract_call_method, there's a heuristic that should be changed to reflect the new signature:
# the construct-to-convert method is a bottleneck in inference,
# so just assume that recursion will get prevented at some other point
&& !(method.sig == Tuple{Type, Any}))
that should address the inference failure in mmap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we suggested that this should be:
convert(::Type{I}, x) where {I <: Number} = I(x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it maybe should be eventually, I was just being conservative for now.
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
Ah, what happened here was that the type assertion in
was very helpful to inference in some cases. The new constructors are all inferable, but there are too many of them, so we hit the method match limit (#23210). |
Can we just remove that limit? |
That would be a good experiment. I guess we can rely on the property that worse type information will tend to make the inferred return type diverge to |
Here's a small wrinkle. It's pretty popular to define highly generic conversions like these:
Do we want these to be constructors? We could certainly move to a world where things like this are defined as constructors by default, with only a relatively small number of |
That second one should never have existed as a method of convert, so +1 to continuing with the plan. |
I looked into the couple slowdowns here. I can reproduce the |
We should also merge #22300 |
Updated to change all |
7c4b35b
to
6b8f5eb
Compare
0130c1c
to
0c8b5e7
Compare
e4b4d70
to
8163010
Compare
66cde46
to
c39b5ff
Compare
Yes, it will. Jeff is on vacation for the week. |
Getting this after rebase, if somebody wants to dig in:
|
15fbb7b
to
002fb2f
Compare
Fixed that issue and rebased; let's see what happens now. |
002fb2f
to
7e44cc0
Compare
AbstractMatrix(C::Cholesky) = C.uplo == 'U' ? C[:U]'C[:U] : C[:L]*C[:L]' | ||
AbstractArray(C::Cholesky) = AbstractMatrix(C) | ||
Matrix(C::Cholesky) = Array(AbstractArray(C)) | ||
Array(C::Cholesky) = Matrix(C) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful! :) All factorization->array convert methods become array constructors in this pull request I imagine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so.
This has gotten a bit out of hand with the large number of changes happening, but please bear with me. I think we really need this in 1.0 --- it can't be handled neatly by renaming or deprecations. |
100% agree; just take care of it when you're back! |
7e44cc0
to
6bc8186
Compare
Tests passing again! Anybody know if these CircleCI failures are new? |
Nope, not new. |
They're not new, but they're unrelated afaict. They're both remote worker exceptions and Linux builds pass on Travis, so I think you're in the clear here. Circle CI has been shot for the past week or more. |
@JeffBezanson, you should probably merge this when you're ready – it's passing CI and we don't want to let it get any new conflicts! |
6bc8186
to
575187d
Compare
Instead, define explicit constructors for built-in integer types in boot.jl.
deprecate a few more sketchy `convert` methods
575187d
to
31006cf
Compare
🎉 |
This resolves #15120. The approach used here is to define explicit constructors for all types (as a bonus, it's nice that more constructors can be defined in
Core
where the types themselves are defined), and then addconvert
methods to indicate which constructors are safe for use in conversion. This also has the nice side effect of removing an unsightly warning from the system image build, sinceCore.Inference
can work without the fallback constructor.@nanosoldier
runbenchmarks(ALL, vs=":master")