DEV Community

Discussion on: Do Python One-Liners Make Your Code Faster?

Collapse
 
matthewpersico profile image
Matthew O. Persico • Edited

I’m astonished by the above results.

You shouldn't be. Loops are notorious for being slow due to the iterator being accessed and manipulated. You have just discovered in Python what we've known in Perl for years: less code is faster. We use map and grep liberally in Perl and then get accused of being "too clever". Welcome to reality!

Collapse
 
naveenkumarmd profile image
Naveenkumar M

Thanks for the informative reply Mr. Matthew