Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (11 sloc) 1.22 KB
Originally my generate_uncompressed() time took 45 seconds, but I managed to get it to just under 20 seconds (I was testing with dan.bmp).
I did this by doing a lot of reading online on how to make python code more efficient. I learned about things like:
- Tail recursion
- Try/except blocks being lest costly than if/else blocks
- ‘.join()’ being less costly than string concatenation
- Mutating a list is less costly than returning something every time
And a lot more! I also did things like create a dictionary with symbols that were already found, so they wouldn’t have to be searched again. Eventually my generate_uncompressed was making 10 million recursive calls as opposed to 20 million (for dan.bmp)!
I also decreased the uncompression time by creating a new method of uncompressing, which works with dictionaries, and would be faster for small files. I coded a recursive function to handle larger files because the python dictionaries crashed when I tried to insert symbols in the billions.
I've actually wondered before, how things like WinRar works and such, and found it really facinating to learn about. I had a lot of fun doing this assignment! I hope you can have just as much fun marking it! :)