Hacker News new | past | comments | ask | show | jobs | submit login

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




Comprehensions have their own opcodes which directly call e.g. PyList_Append with no further checks or lookups in each iteration.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: