I was reading the code for the timeit module and I noticed this segment:
gcold = gc.isenabled()
gc.disable()
timing = self.inner(it, self.timer)
if gcold:
gc.enable()
This just stores the state of garbage collection (on or off) and then turns it off. The function inner
executes the statement being timed. It then reverts the garbage collector to its old state.
So I'm curious about what the point of this is. If the code being tested works the garbage collector, then shouldn't that be reflected in the testing? What am I missing?