From the source of shared_memory.py,
sum() is invoked on
_allocated_bytes, which is a tuple of ints. So, while the complexity of
sum() is O(n), the operation should be rather fast at n=99,999, e.g.,
timeit.timeit(‘sum(tuple( * 99999))’, number=1) took 0.001508065004600212s on my computer. Hence, I doubt if
sum() operation is the reason for the slowdown.