for obj in abc.__subclasses__() + [abc]:
abcs[obj] = obj._abc_registry.copy()
+ # bpo-31217: Integer pool to get a single integer object for the same
+ # value. The pool is used to prevent false alarm when checking for memory
+ # block leaks. Fill the pool with values in -1000..1000 which are the most
+ # common (reference, memory block, file descriptor) differences.
+ int_pool = {value: value for value in range(-1000, 1000)}
+ def get_pooled_int(value):
+ return int_pool.setdefault(value, value)
+
nwarmup, ntracked, fname = huntrleaks
fname = os.path.join(support.SAVEDCWD, fname)
repcount = nwarmup + ntracked
abcs)
print('.', end='', file=sys.stderr, flush=True)
if i >= nwarmup:
- rc_deltas[i] = rc_after - rc_before
- alloc_deltas[i] = alloc_after - alloc_before
- fd_deltas[i] = fd_after - fd_before
+ rc_deltas[i] = get_pooled_int(rc_after - rc_before)
+ alloc_deltas[i] = get_pooled_int(alloc_after - alloc_before)
+ fd_deltas[i] = get_pooled_int(fd_after - fd_before)
alloc_before = alloc_after
rc_before = rc_after
fd_before = fd_after