3 ms·
Don't you mean a python set? But yes, for use cases containing many duplicates where the result easily fits in memory, that is probably the fastest.
by jtwaleson 11y ago
Don't you mean a python set? But yes, for use cases containing many duplicates where the result easily fits in memory, that is probably the fastest.
- bacr 11y agoFun fact: they are nearly the same implementation. See: http://markmail.org/message/ktzomp4uwrmnzao6 http://markmail.org/message/ktzomp4uwrmnzao6
- masklinn 11y agoAs one would generally expect, the backing store of most hashsets is little more than a hashmap with zero-sized/no values. In fact, that's exactly how Rust's standard library hashset is implemented since rust supports zero-sized types "in userland" (and unit `()` is a ZST): pub struct HashSet<T, S = RandomState> { map: HashMap<T, (), S> } http://doc.rust-lang.org/src/std/collections/hash/set.rs.html#112-114 http://doc.rust-lang.org/src/std/collections/hash/set.rs.htm...
- justinsaccount 11y agoa set replaces 'sort -u' or 'sort | uniq'. A dictionary replaces 'sort | uniq -c'