We have three ways for this:
- Multi-threading | Multi-processing
- Compiler
- Change the Code
Let start with Threads you can simply use them to maybe download many files faster since else you would have to wait until one image is downloaded and then you can start the next download.
To read more about that go to https://towardsdatascience.com/did-you-know-how-to-make-your-python-code-run-faster-1st-installment-f317359159a1
Next is using another compiler for example PyPy:
Now why should you use it and why not.
It runs your code nearly 100 times faster than Python does, so that's pretty good but there is a disadvantage since you may have to change your code a little bit since not all packages are available. For more about this got to https://www.geeksforgeeks.org/why-pypy3-is-preffered-over-python3/
The last thing is changing your code for that I found a pretty good blog post that explains how to optimize your code.