Optimizing Memory Usage in Python Applications