How would you optimize a Python script that is currently taking too long to process a large text dataset?