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

Function compress_dhist

IPython/core/magic.py:58–74  ·  view source on GitHub ↗

Compress a directory history into a new one with at most 20 entries. Return a new list made from the first and last 10 elements of dhist after removal of duplicates.

(dh)

Source from the content-addressed store, hash-verified

56
57
58def compress_dhist(dh):
59 """Compress a directory history into a new one with at most 20 entries.
60
61 Return a new list made from the first and last 10 elements of dhist after
62 removal of duplicates.
63 """
64 head, tail = dh[:-10], dh[-10:]
65
66 newhead = []
67 done = set()
68 for h in head:
69 if h in done:
70 continue
71 newhead.append(h)
72 done.add(h)
73
74 return newhead + tail
75
76
77def needs_local_scope(func):

Callers 1

cdMethod · 0.90

Calls 1

addMethod · 0.45

Tested by

no test coverage detected