Manipulating large objects in Python