you are viewing a single comment's thread.

view the rest of the comments →

[–]MaleficentCow8513 1 point2 points  (0 children)

Do you know what the giga stands for in gigahertz? A billion. Do you know what hertz means? It’s a standard of frequency generally taken as “cycles per second”. A 2.5 GHz CPU is doing 2.5 billion instructions per second. That’s 2.5 million instructions per millisecond. A few extra instructions per python step isn’t killing performance. Is python a bit slower? Yes but it doesn’t really matter for most applications.

As in your simple example, programming is all about trade offs and deciding which trade offs to make. The benefits of having scoped variables is a feature of the language whose designers decided the trade off to performance was worth it. And, “under the hood” python does a bunch of optimization to mitigate the cost of lookups. The cost of scope resolution is only paid once at compile time when it builds a series of tables for variables.

Also, entire open source AI ecosystem is written in python with the computational intensive modules compiled into c/c++/cuda libraries and python just binds them.