4 ms·
Localizing append helps, but that's not all of it: Building a list of 10,000,000 items: List comprehension: 599ms For loop: 930ms For loop with append localiz
by lilbobbytables 9y ago
Localizing append helps, but that's not all of it:
Building a list of 10,000,000 items:
List comprehension: 599ms
For loop: 930ms
For loop with append localized: 736ms
- dom0 9y agoComprehensions have their own opcodes which directly call e.g. PyList_Append with no further checks or lookups in each iteration.