An ordered dictionary of keys provides a compact way to deduplicate hashable values in first-seen order.
Worked example
values = [3, 1, 3, 2]
print(list(dict.fromkeys(values)))Result
[3, 1, 2]Implementation notes
Two equal values with different display forms collapse to one stored key. Decide whether that first display form should be retained or normalized.
Try it yourself
Compare repeated integers with an input containing an unhashable list.
Open the Python example →Editorial date October 9, 2025 · Published December 6, 2026