Skip to content

Commit eb01a80

Browse files
authored
Merge branch 'master' into range_one_kw_only
2 parents bd6cd3c + 927c24f commit eb01a80

File tree

166 files changed

+5008
-1472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+5008
-1472
lines changed

Make.inc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,6 @@ CXX_DISABLE_ASSERTION := -DJL_NDEBUG
454454
DISABLE_ASSERTIONS := -DNDEBUG -DJL_NDEBUG
455455
endif
456456

457-
ifeq ($(LLVM_ASSERTIONS),0)
458-
CXX_DISABLE_ASSERTION += -DNDEBUG
459-
endif
460-
461457
# Compiler specific stuff
462458

463459
ifeq ($(USEMSVC), 1)
@@ -1200,12 +1196,6 @@ endef
12001196
$(foreach proj,$(BB_PROJECTS),$(eval $(call SET_BB_DEFAULT,$(proj))))
12011197

12021198

1203-
1204-
# Use the Assertions build
1205-
BINARYBUILDER_LLVM_ASSERTS ?= 0
1206-
1207-
1208-
12091199
# OS specific stuff
12101200

12111201
# install_name_tool

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Julia v1.7 Release Notes
44
New language features
55
---------------------
66

7+
* `(; a, b) = x` can now be used to destructure properties `a` and `b` of `x`. This syntax is equivalent to `a = getproperty(x, :a)`
8+
and similarly for `b`. ([#39285])
9+
710
Language changes
811
----------------
912

@@ -47,6 +50,8 @@ Standard library changes
4750
* `escape_string` can now receive a collection of characters in the keyword
4851
`keep` that are to be kept as they are. ([#38597]).
4952
* `getindex` can now be used on `NamedTuple`s with multiple values ([#38878])
53+
* `keys(::RegexMatch)` is now defined to return the capture's keys, by name if named, or by index if not ([#37299]).
54+
* `RegexMatch` now iterate to give their captures. ([#34355]).
5055

5156
#### Package Manager
5257

base/Base.jl

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -394,37 +394,36 @@ in_sysimage(pkgid::PkgId) = pkgid in _sysimage_modules
394394
# Precompiles for Revise
395395
# TODO: move these to contrib/generate_precompile.jl
396396
# The problem is they don't work there
397-
let m = which(+, (Int, Int))
398-
while true # defeat interpreter heuristic to force compilation
399-
delete!(push!(Set{Method}(), m), m)
400-
copy(Core.Compiler.retrieve_code_info(Core.Compiler.specialize_method(m, [Int, Int], Core.svec())))
401-
402-
empty!(Set())
403-
push!(push!(Set{Union{GlobalRef,Symbol}}(), :two), GlobalRef(Base, :two))
404-
(setindex!(Dict{String,Base.PkgId}(), Base.PkgId(Base), "file.jl"))["file.jl"]
405-
(setindex!(Dict{Symbol,Vector{Int}}(), [1], :two))[:two]
406-
(setindex!(Dict{Base.PkgId,String}(), "file.jl", Base.PkgId(Base)))[Base.PkgId(Base)]
407-
(setindex!(Dict{Union{GlobalRef,Symbol}, Vector{Int}}(), [1], :two))[:two]
408-
(setindex!(IdDict{Type, Union{Missing, Vector{Tuple{LineNumberNode, Expr}}}}(), missing, Int))[Int]
409-
Dict{Symbol, Union{Nothing, Bool, Symbol}}(:one => false)[:one]
410-
Dict(Base => [:(1+1)])[Base]
411-
Dict(:one => [1])[:one]
412-
Dict("abc" => Set())["abc"]
413-
pushfirst!([], sum)
414-
get(Base.pkgorigins, Base.PkgId(Base), nothing)
415-
sort!([1,2,3])
416-
unique!([1,2,3])
417-
cumsum([1,2,3])
418-
append!(Int[], BitSet())
419-
isempty(BitSet())
420-
delete!(BitSet([1,2]), 3)
421-
deleteat!(Int32[1,2,3], [1,3])
422-
deleteat!(Any[1,2,3], [1,3])
423-
Core.svec(1, 2) == Core.svec(3, 4)
424-
any(t->t[1].line > 1, [(LineNumberNode(2,:none), :(1+1))])
425-
426-
break # end defeat interpreter heuristic
427-
end
397+
for match = _methods(+, (Int, Int), -1, get_world_counter())
398+
m = match.method
399+
delete!(push!(Set{Method}(), m), m)
400+
copy(Core.Compiler.retrieve_code_info(Core.Compiler.specialize_method(match)))
401+
402+
empty!(Set())
403+
push!(push!(Set{Union{GlobalRef,Symbol}}(), :two), GlobalRef(Base, :two))
404+
(setindex!(Dict{String,Base.PkgId}(), Base.PkgId(Base), "file.jl"))["file.jl"]
405+
(setindex!(Dict{Symbol,Vector{Int}}(), [1], :two))[:two]
406+
(setindex!(Dict{Base.PkgId,String}(), "file.jl", Base.PkgId(Base)))[Base.PkgId(Base)]
407+
(setindex!(Dict{Union{GlobalRef,Symbol}, Vector{Int}}(), [1], :two))[:two]
408+
(setindex!(IdDict{Type, Union{Missing, Vector{Tuple{LineNumberNode, Expr}}}}(), missing, Int))[Int]
409+
Dict{Symbol, Union{Nothing, Bool, Symbol}}(:one => false)[:one]
410+
Dict(Base => [:(1+1)])[Base]
411+
Dict(:one => [1])[:one]
412+
Dict("abc" => Set())["abc"]
413+
pushfirst!([], sum)
414+
get(Base.pkgorigins, Base.PkgId(Base), nothing)
415+
sort!([1,2,3])
416+
unique!([1,2,3])
417+
cumsum([1,2,3])
418+
append!(Int[], BitSet())
419+
isempty(BitSet())
420+
delete!(BitSet([1,2]), 3)
421+
deleteat!(Int32[1,2,3], [1,3])
422+
deleteat!(Any[1,2,3], [1,3])
423+
Core.svec(1, 2) == Core.svec(3, 4)
424+
any(t->t[1].line > 1, [(LineNumberNode(2,:none), :(1+1))])
425+
426+
break # only actually need to do this once
428427
end
429428

430429
if is_primary_base_module

base/abstractarray.jl

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ function _getindex(::IndexLinear, A::AbstractArray, I::Vararg{Int,M}) where M
11931193
end
11941194
_to_linear_index(A::AbstractArray, i::Integer) = i
11951195
_to_linear_index(A::AbstractVector, i::Integer, I::Integer...) = i
1196-
_to_linear_index(A::AbstractArray) = 1
1196+
_to_linear_index(A::AbstractArray) = first(LinearIndices(A))
11971197
_to_linear_index(A::AbstractArray, I::Integer...) = (@_inline_meta; _sub2ind(A, I...))
11981198

11991199
## IndexCartesian Scalar indexing: Canonical method is full dimensionality of Ints
@@ -1481,7 +1481,7 @@ vcat(V::AbstractVector{T}...) where {T} = typed_vcat(T, V...)
14811481
# but that solution currently fails (see #27188 and #27224)
14821482
AbstractVecOrTuple{T} = Union{AbstractVector{<:T}, Tuple{Vararg{T}}}
14831483

1484-
_typed_vcat_similar(V, T, n) = similar(V[1], T, n)
1484+
_typed_vcat_similar(V, ::Type{T}, n) where T = similar(V[1], T, n)
14851485
_typed_vcat(::Type{T}, V::AbstractVecOrTuple{AbstractVector}) where T =
14861486
_typed_vcat!(_typed_vcat_similar(V, T, mapreduce(length, +, V)), V)
14871487

@@ -1577,9 +1577,10 @@ cat_size(A::AbstractArray, d) = size(A, d)
15771577
cat_indices(A, d) = OneTo(1)
15781578
cat_indices(A::AbstractArray, d) = axes(A, d)
15791579

1580-
cat_similar(A, T, shape) = Array{T}(undef, shape)
1581-
cat_similar(A::AbstractArray, T, shape) = similar(A, T, shape)
1580+
cat_similar(A, ::Type{T}, shape) where T = Array{T}(undef, shape)
1581+
cat_similar(A::AbstractArray, ::Type{T}, shape) where T = similar(A, T, shape)
15821582

1583+
# These are for backwards compatibility (even though internal)
15831584
cat_shape(dims, shape::Tuple{Vararg{Int}}) = shape
15841585
function cat_shape(dims, shapes::Tuple)
15851586
out_shape = ()
@@ -1588,6 +1589,11 @@ function cat_shape(dims, shapes::Tuple)
15881589
end
15891590
return out_shape
15901591
end
1592+
# The new way to compute the shape (more inferrable than combining cat_size & cat_shape, due to Varargs + issue#36454)
1593+
cat_size_shape(dims) = ntuple(zero, Val(length(dims)))
1594+
@inline cat_size_shape(dims, X, tail...) = _cat_size_shape(dims, _cshp(1, dims, (), cat_size(X)), tail...)
1595+
_cat_size_shape(dims, shape) = shape
1596+
@inline _cat_size_shape(dims, shape, X, tail...) = _cat_size_shape(dims, _cshp(1, dims, shape, cat_size(X)), tail...)
15911597

15921598
_cshp(ndim::Int, ::Tuple{}, ::Tuple{}, ::Tuple{}) = ()
15931599
_cshp(ndim::Int, ::Tuple{}, ::Tuple{}, nshape) = nshape
@@ -1631,36 +1637,37 @@ _cat(dims, X...) = cat_t(promote_eltypeof(X...), X...; dims=dims)
16311637
@inline cat_t(::Type{T}, X...; dims) where {T} = _cat_t(dims, T, X...)
16321638
@inline function _cat_t(dims, ::Type{T}, X...) where {T}
16331639
catdims = dims2cat(dims)
1634-
shape = cat_shape(catdims, map(cat_size, X))
1640+
shape = cat_size_shape(catdims, X...)
16351641
A = cat_similar(X[1], T, shape)
16361642
if count(!iszero, catdims)::Int > 1
16371643
fill!(A, zero(T))
16381644
end
16391645
return __cat(A, shape, catdims, X...)
16401646
end
16411647

1642-
function __cat(A, shape::NTuple{M}, catdims, X...) where M
1643-
N = M::Int
1644-
offsets = zeros(Int, N)
1645-
inds = Vector{UnitRange{Int}}(undef, N)
1646-
concat = copyto!(zeros(Bool, N), catdims)
1647-
for x in X
1648-
for i = 1:N
1649-
if concat[i]
1650-
inds[i] = offsets[i] .+ cat_indices(x, i)
1651-
offsets[i] += cat_size(x, i)
1652-
else
1653-
inds[i] = 1:shape[i]
1654-
end
1655-
end
1656-
I::NTuple{N, UnitRange{Int}} = (inds...,)
1657-
if x isa AbstractArray
1658-
A[I...] = x
1659-
else
1660-
fill!(view(A, I...), x)
1661-
end
1648+
# Why isn't this called `__cat!`?
1649+
__cat(A, shape, catdims, X...) = __cat_offset!(A, shape, catdims, ntuple(zero, length(shape)), X...)
1650+
1651+
function __cat_offset!(A, shape, catdims, offsets, x, X...)
1652+
# splitting the "work" on x from X... may reduce latency (fewer costly specializations)
1653+
newoffsets = __cat_offset1!(A, shape, catdims, offsets, x)
1654+
return __cat_offset!(A, shape, catdims, newoffsets, X...)
1655+
end
1656+
__cat_offset!(A, shape, catdims, offsets) = A
1657+
1658+
function __cat_offset1!(A, shape, catdims, offsets, x)
1659+
inds = ntuple(length(offsets)) do i
1660+
(i <= length(catdims) && catdims[i]) ? offsets[i] .+ cat_indices(x, i) : 1:shape[i]
1661+
end
1662+
if x isa AbstractArray
1663+
A[inds...] = x
1664+
else
1665+
fill!(view(A, inds...), x)
1666+
end
1667+
newoffsets = ntuple(length(offsets)) do i
1668+
(i <= length(catdims) && catdims[i]) ? offsets[i] + cat_size(x, i) : offsets[i]
16621669
end
1663-
return A
1670+
return newoffsets
16641671
end
16651672

16661673
"""

base/binaryplatforms.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct Platform <: AbstractPlatform
7171
if isa(value, VersionNumber)
7272
value = string(value)
7373
elseif isa(value, AbstractString)
74-
v = tryparse(VersionNumber, value)
74+
v = tryparse(VersionNumber, String(value))
7575
if isa(v, VersionNumber)
7676
value = string(v)
7777
end

base/broadcast.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ const NonleafHandlingStyles = Union{DefaultArrayStyle,ArrayConflict}
924924
# Now handle the remaining values
925925
# The typeassert gives inference a helping hand on the element type and dimensionality
926926
# (work-around for #28382)
927-
ElType′ = ElType <: Type ? Type : ElType
927+
ElType′ = ElType === Union{} ? Any : ElType <: Type ? Type : ElType
928928
RT = dest isa AbstractArray ? AbstractArray{<:ElType′, ndims(dest)} : Any
929929
return copyto_nonleaf!(dest, bc′, iter, state, 1)::RT
930930
end
@@ -977,8 +977,10 @@ preprocess_args(dest, args::Tuple{}) = ()
977977
end
978978
end
979979
bc′ = preprocess(dest, bc)
980-
@simd for I in eachindex(bc′)
981-
@inbounds dest[I] = bc′[I]
980+
# Performance may vary depending on whether `@inbounds` is placed outside the
981+
# for loop or not. (cf. https://github.com/JuliaLang/julia/issues/38086)
982+
@inbounds @simd for I in eachindex(bc′)
983+
dest[I] = bc′[I]
982984
end
983985
return dest
984986
end

0 commit comments

Comments
 (0)