Program uses twice as much memory in Python 3.6 than in Python 3.5