This is really two questions, but they are so similar, and to keep it simple, I figured I\'d just roll them together:
Firstly: Given an est
For an established project I feel the main performance gain will be from making use of python internal lib as much as possible.
Some tips are here: http://blog.hackerearth.com/faster-python-code