Python coding tips for efficiency