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?