Python: sped up gi-ne max index calculation.