As you've seen in many of the other solutions, it's pretty feasible to re-frame your original implementation as a generator, and this increases legibility.
Add unit tests.
I disregard your memory tag ...
Place the class right after the imports. Having the class between other
lines of code disrupts the natural flow of the code.
You should also add blank lines between the functions.