I just released my latest book, Fast Python: Master the Basics to Write Faster Code. In it, you will find a blend of academic discussion of algorithms and a pragmatic optimizations of computation time.
Whether or not you are interested in buying the book, I wanted to share some free resources from the accompanying GitHub repository. These code profiles can be run as stand-alone scripts. They show how different versions of the same algorithm perform across different sizes of input arguments. The charts and tables are pretty cool. I hope others can find use in the accompanying profiling library, as well.
- Binary search: binary_search.py
- Dictionary construction: build_dict.py
- Concatenating strings, string construction: concatenate_strings.py
- Counting the frequency of a value: count_occurrences.py
- Computing a cumulative sum: cumulative_sum.py
- The
in
operator and early stopping: early_stopping.py - Time series filters/convolutions: filters.py
- Find largest
k
values in a list: find_top_k.py - List construction/declaration/flattening: flatten_lists.py
- Counting lines in a file: line_count.py
- Set intersection, finding matches in a list: match_within.py
- Matrix multiplication: matrix_multiplication.py
- Computing moving averages: moving_averages.py
- Counting frequency of a word in text: occurrences_of.py
- Looping through
pd.DataFrame
objects: pandas_loops.py - Sorting algorithms: sorting.py
- Low-level sorting algorithms: sorting_v2.py
- Adding a list of numbers: sum.py
Leave a Reply