Cpy versus Python for efficiency

  • 2020-04-02 14:43:58
  • OfStack

Beginners to the Python language, especially the "amazers "(those who are attracted to a feature that makes no sense at first and then continue to convince themselves), think that Python doesn't need a for statement in C because they can use the elegant Python for instead of a c-like for.

Cpy cycle:


for(i=s; i<num; i+=step){
}

Python loop:

for i in range(num)[s:e:step]:

Recently, I wrote a 100000000 loop of code, and unfortunately (as expected), Python ran out of machine memory and left my Windows running out of virtual memory.

The Cpy loop is stress-free and USES up very little memory.


Related articles: