DEV Community

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

hanpari profile image
Pavel Morava

As for your last one liner, it seems rather unnecessary to create another string. You may want to use built-ins like all and reverse to avoid new memory allocation.

The case may be that creating new string and compare them is faster, but still, for longer array I don't think it's a good idea do it your way.

naveenkumarmd profile image
Naveenkumar M Author

yeah Thanks for that. I have not noticed it.