MCPcopy Index your code
hub / github.com/ipython/ipython / compress_dhist

Function compress_dhist

IPython/core/magic.py:67–83  ·  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: list[str])

Source from the content-addressed store, hash-verified

65
66
67def compress_dhist(dh: list[str]) -> list[str]:
68 """Compress a directory history into a new one with at most 20 entries.
69
70 Return a new list made from the first and last 10 elements of dhist after
71 removal of duplicates.
72 """
73 head, tail = dh[:-10], dh[-10:]
74
75 newhead: list[str] = []
76 done: set[str] = set()
77 for h in head:
78 if h in done:
79 continue
80 newhead.append(h)
81 done.add(h)
82
83 return newhead + tail
84
85
86def needs_local_scope(func: _F) -> _F:

Callers 1

cdMethod · 0.90

Calls 1

addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…