MCPcopy Index your code
hub / github.com/RustPython/RustPython / pop_and_collect

Method pop_and_collect

Lib/test/test_weakref.py:2002–2009  ·  view source on GitHub ↗
(lst)

Source from the content-addressed store, hash-verified

2000 exc.append(ex)
2001
2002 def pop_and_collect(lst):
2003 gc_ctr = 0
2004 while lst:
2005 i = random.randint(0, len(lst) - 1)
2006 gc_ctr += 1
2007 lst.pop(i)
2008 if gc_ctr % 10000 == 0:
2009 gc.collect() # just in case
2010
2011 self.assertIn(type_, (weakref.WeakKeyDictionary, weakref.WeakValueDictionary))
2012

Callers

nothing calls this directly

Calls 4

lenFunction · 0.85
randintMethod · 0.80
collectMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected