Improve Python Run-time Without Changing A Single Line of Code
Switching to a smarter implementation of CPython.
Python's default interpreter — CPython, isn't smart at dealing with for-loops, lists, and more.
It serves as a standard interpreter for Python and offers no built-in optimization.
Pypy, however, is an alternative implementation of CPython, which is much smarter.
How does it work?
It takes existing Python code and generates fast machine code using just-in-time compilation.
As a result, post compilation, the code runs at native machine code speed.
And Pypy can be used without modifying a single line of existing Python code.
👉 You should consider Pypy when:
you're dealing with standard Python objects.
speedups aren't possible with NumPy/Pandas.
When you have some native Python code, don't run it with the default interpreter of Python.
Instead, look for alternative smarter implementations, such as Pypy.
Pypy will help you:
improve run-time of code, and
execute it at machine speed,
without modifying the code.
Find some more benchmarking results between Python and Pypy below:
Get started with Pypy here: Pypy docs.
👉 Over to you: What are some other smarter implementations of Python interpreter?
Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.
If you haven’t noticed yet, I have grouped all my daily posts based on topics, as shown below:
Head over to the home page here: Daily Dose of Data Science, and enjoy reading posts from your preferred topics :)
Also, I recently noticed that the Daily Dose of Data Science now stands among the top 50 tech newsletters on Substack among thousands of other newsletters. And this happened in just 7 months of its inception.
So once again, thanks a lot for your immense support towards this newsletter 😇.
Have a good day!
👉 Read what others are saying about this post on LinkedIn and Twitter.
👉 Tell the world what makes this newsletter special for you by leaving a review here :)
👉 If you liked this post, don’t forget to leave a like ❤️. It helps more people discover this newsletter on Substack and tells me that you appreciate reading these daily insights. The button is located towards the bottom of this email.
👉 If you love reading this newsletter, feel free to share it with friends!
Find the code for my tips here: GitHub.
I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn and Twitter.