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

Method cull_cache

IPython/core/displayhook.py:270–282  ·  view source on GitHub ↗

Output cache is full, cull the oldest entries

(self)

Source from the content-addressed store, hash-verified

268 self.finish_displayhook()
269
270 def cull_cache(self):
271 """Output cache is full, cull the oldest entries"""
272 oh = self.shell.user_ns.get('_oh', {})
273 sz = len(oh)
274 cull_count = max(int(sz * self.cull_fraction), 2)
275 warn('Output cache limit (currently {sz} entries) hit.\n'
276 'Flushing oldest {cull_count} entries.'.format(sz=sz, cull_count=cull_count))
277
278 for i, n in enumerate(sorted(oh)):
279 if i >= cull_count:
280 break
281 self.shell.user_ns.pop('_%i' % n, None)
282 oh.pop(n, None)
283
284
285 def flush(self):

Callers 1

update_user_nsMethod · 0.95

Calls 2

popMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected