Most of the time that Python scripts take to run when working with Cerebro API is used for database queries.
To speed that process up, try using arrays for queries where possible.
For example, many Server API functions such as message_attachments, messages, task_attachments support arrays of message or task IDs as input. One query with an array of IDs will take less time to run than several queries with different single IDs.