Closed as not planned
Description
F# list's List.Equals
always performs full structural comparison, even if the two objects being compared are the same object.
Repro steps
open System.Diagnostics
let swList = Stopwatch.StartNew()
let l = [1..1000000]
for i in [1..100] do
if l.Equals(l) = false then
failwith "Not equal"
printfn $"List: {swList.Elapsed}"
let swArray = Stopwatch.StartNew()
let a = [|1..1000000|]
for i in [1..100] do
if a.Equals(a) = false then
failwith "Not equal"
printfn $"Array: {swArray.Elapsed}"
Expected behavior
List and array-based code should be equally quick.
Actual behavior
List is much slower:
List: 00:00:02.2389815
Array: 00:00:00.0114506
Known workarounds
- Use object equality explicitly before using
List.Equals
- Use other collection types
Metadata
Metadata
Assignees
Type
Projects
Status
Done