New in version 1.1.0.
Collection utilities
| Parameters: |
|
|---|---|
| Return type: | list |
Return a list of the elements in seq, but without duplicates.
For example, unique([1,2,3,1,2,3]) is some permutation of [1,2,3], unique("abcabc") some permutation of ["a", "b", "c"], and unique(([1, 2], [2, 3], [1, 2])) some permutation of [[2, 3], [1, 2]].
For best speed, all sequence elements should be hashable. Then unique() will usually work in linear time.
If not possible, the sequence elements should enjoy a total ordering, and if list(s).sort() doesn’t raise TypeError it’s assumed that they do enjoy a total ordering. Then unique() will usually work in O(N*log2(N)) time.
If that’s not possible either, the sequence elements must support equality-testing. Then unique() will usually work in quadratic time.
| Parameters: |
|
|---|---|
| Return type: | list |