optimized for performance

Hmm, it seems my first try for Python gave me truly poor performance
because of my stupid code.