叫chatgpt幫測,他還幫我改code XDDD 但最後的答案是 List comprehension (Method 2) is usually the fastest and most Pythonic. map() (Method 3) can be slightly slower or similar, depending on the context and Python implementation. For loop (Method 1) is generally the slowest because of the overhead of method calls and append.
CC_27: 他生了code,我昨天忘了叫他跑,現在叫他跑過了。 For loop with append(): 0.368 seconds List comprehension: 0.219 seconds map() function: 0.204 seconds reduce() with summing: 0.175 seconds (not directly comparable to the others)