MCPcopy Create free account
hub / github.com/ipython/ipython / uniq_stable

Function uniq_stable

IPython/utils/data.py:13–23  ·  view source on GitHub ↗

uniq_stable(elems) -> list Return from an iterable, a list of all the unique elements in the input, but maintaining the order in which they first appear. Note: All elements in the input must be hashable for this routine to work, as it internally uses a set for efficiency reasons.

(elems)

Source from the content-addressed store, hash-verified

11
12
13def uniq_stable(elems):
14 """uniq_stable(elems) -> list
15
16 Return from an iterable, a list of all the unique elements in the input,
17 but maintaining the order in which they first appear.
18
19 Note: All elements in the input must be hashable for this routine
20 to work, as it internally uses a set for efficiency reasons.
21 """
22 seen = set()
23 return [x for x in elems if x not in seen and not seen.add(x)]
24
25
26def chop(seq, size):

Callers 1

format_recordMethod · 0.90

Calls 1

addMethod · 0.45

Tested by

no test coverage detected