Well, how everyone guesses ...
As the OP said, each key is unique. For an array or data set, the dictionary code must collect the keys - the cost of this applies to both. In the given case, each key should be added to the set, which includes (membershipless, as it turns out) a membership test, while in the case of an array, a membership test is not required - the cost of adding to the array should be less than adding to the set. The array wins.
source share