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

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more