Discover more from Daily Dose of Data Science
Vectorization Does Not Always Guarantee Better Performance
Vectorization is well-adopted for improving run-time performance. In a nutshell, it lets you operate data in batches instead of processing a single value at a time.
Although vectorization is extremely effective, you should know that it does not always guarantee performance gains. Moreover, vectorization is also associated with memory overheads.
As demonstrated above, the non-vectorized code provides better performance than the vectorized version.
P.S. 𝐚𝐩𝐩𝐥𝐲() is also a for-loop.
Further reading: Here.
Share this post on LinkedIn: Post Link.
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.