Skip to content

sortperm! allocates due to inference/type stability issues #47949

Closed
@LilithHafner

Description

@LilithHafner

I don't know exactly why sortperm! allocates here, but I know that it shouldn't:

julia> v = rand(10);

julia> ix = similar(eachindex(v));

julia> @btime sortperm!($ix, $v) setup=(copyto!($ix, eachindex($v))) evals=1;
  939.000 ns (5 allocations: 336 bytes)

julia> @btime sort!($ix) setup=(sortperm!($ix, $v)) evals=1;
  84.000 ns (0 allocations: 0 bytes)

This is not new in 1.9 but it is slightly worse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions