Why Is NumPy 60× Faster Than Python? NumPy finished our loop about sixty times faster than plain…
Coding Together
Visit on TikTok@cod1ng_together33K followers
13,200 views
Why Is NumPy 60× Faster Than Python? NumPy finished our loop about sixty times faster than plain Python, on the same Mac and with the exact same calculation ⚡ In this video we zoom into one single step and show why: in Python every number is a full object with a type and a counter, 28 bytes instead of eight, and every step means a type check and a brand new object. NumPy checks the type once and runs one tight compiled loop over plain eight byte numbers. Then comes the twist: NumPy's result was actually wrong, because eight bytes only go up to about nine quintillion and the total silently wrapped around, while Python's numbers just grow. So you learn when NumPy is the right tool and when plain Python is the safe choice. Did you know NumPy can overflow like this? #python #coding #programming
Comments
Comments from the original post on TikTok
No comments yet
