In this Bite we provide you with 5 functions which you have to try to make faster. Some require different data structures or tactics. Knowing about these techniques goes a long way specially when your data sets grow and performance becomes an issue.
Notice that:
timing
decorator can be ignored, the tests use this to time each functionbisect
would be a candidate for contains_fast
but we think set
(or dict
) is the best way so this is the only function with a different input argument type for the fast equivalent (type casting was too expensive)For some this may be easy, for others this might be an eye opener, regardless have fun and keep calm and code in Python!