minor performance tweak in python version