S
smisk

collections

New in version 1.1.0.

Collection utilities.

smisk.util.collections.unique_wild(seq)
Parametersseq (collection)
Return typelist

Return unique elements of seq using equality testing. Works for any element type, including unhashable and unorderable items (O(N²) worst case).

smisk.util.collections.unique(seq)
Parametersseq (collection)
Return typelist

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"].

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·log₂N) time.

If that's not possible either, the sequence elements must support equality-testing. Then unique() will usually work in quadratic time.