Comment on Python Performance: Why 'if not list' is 2x Faster Than Using len()
mint_tamas@lemmy.world 5 days agoI think pythonic is more important than performance and I would still choose that version over a try-catch block, were it slower. Being pythonic means it represents a commonly understood pattern in Python code, therefore it is more efficient in communicating intent.
sugar_in_your_tea@sh.itjust.works 5 days ago
Exactly. The point of following a code style is to make obvious patterns easy to spot and deviations stand out. That’s why code style guidelines say your priorities should be:
3 should only be prioritized if the win is big enough, and there should probably be a comment right there explaining why the deviation was made.