DEV Community

Carleii Dev
Carleii Dev

Posted on

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?