improved performance of python sequence iteration (RhBug:1109554)