Last active
October 21, 2020 11:23
-
-
Save ari-hacks/e31437296fabf0276139f82193219c0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Performance Testing Code and APIs | |
""" | |
#Decorators | |
#timeit | |
#cProfile | |
#pyInstrument | |
""" | |
Making Python Faster | |
""" | |
#detailed profiling | |
# -s time: lines are ordered by internal time | |
> python3 -m cProfile -s time file-name.py | |
#Use Built-in data types | |
- Built in data types are written in C, making them more performant | |
#Caching/Memoization with lru_cache | |
> import functools | |
> @functools.lru_cache(maxsize=12).... | |
#Use Local Variables | |
- | |
#Use Functions | |
#Dont Access Attributes | |
#Cuation when using Strings | |
#Generators | |
## More tips and resources | |
> https://dev.to/martinheinz/python-tips-and-trick-you-haven-t-already-seen-1p41 | |
> https://martinheinz.dev/blog/4 | |
> https://stackify.com/20-simple-python-performance-tuning-tips/ | |
> https://wiki.python.org/moin/PythonSpeed/PerformanceTips | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment