# Fastest way to \`unique!\`

**URL:** <https://discourse.julialang.org/t/fastest-way-to-unique/47952>\
**Category:** General Usage\
**Created:** [October 7, 2020, 8:13pm UTC](https://discourse.julialang.org/t/fastest-way-to-unique/47952 "2020-10-07T20:13:21Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 9, 2020, 10:41am UTC](https://discourse.julialang.org/t/fastest-way-to-unique/47952/8 "2020-10-09T10:41:57Z")

</div>

Use an [`OrderedSet`](https://juliacollections.github.io/DataStructures.jl/latest/ordered_containers/), only insert new elements, collect when done.

> **[GitHub - andyferris/Dictionaries.jl: An alternative interface for...](https://github.com/andyferris/Dictionaries.jl)**
>
> An alternative interface for dictionaries in Julia, for improved productivity and performance - GitHub - andyferris/Dictionaries.jl: An alternative interface for dictionaries in Julia, for improved...

also preserves order AFAIK and has a cool API to avoid hash table lookups twice.

---

_[View the full topic](https://discourse.julialang.org/t/fastest-way-to-unique/47952)._
