DEV Community

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

Collapse
matthewpersico profile image
Matthew O. Persico • Edited on

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
hanpari profile image
Pavel Morava

It depends on what is happening under the hood. Less code doesn't need necessarily faster and vice versa.

Collapse
naveenkumarmd profile image
Naveenkumar M Author

Yeah it depends.i totally agree with your point

Collapse
naveenkumarmd profile image
Naveenkumar M Author

Thanks for the informative reply Mr. Matthew