DEV Community

Carleii Dev
Carleii Dev

Posted on

4 2

Powerful one line codes in python

Image description

Top comments (3)

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited
even_numbers = [x for x in range(11) if ~x&1]
even_numbers = [x for x in range(11) if not x&1]
Enter fullscreen mode Exit fullscreen mode

One of these are probably quicker if you care about micro-optimising for speed

Collapse
 
carleii_dev profile image
Carleii Dev

Nice one thanks

Collapse
 
juanitomint profile image
Juan Ignacio Borda

Do you think the compiler (JIT) will tokenize'em differently?

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay