Chalarangelo / 30-seconds-of-python

Short Python code snippets for all your development needs
https://www.30secondsofcode.org/python/p/1
Creative Commons Attribution 4.0 International
8.83k stars 1.26k forks source link

[ENHANCEMENT] Use and instead of bitwise and #108

Closed defterade closed 5 years ago

defterade commented 5 years ago

Description

and is faster

>>> timeit.timeit('[x >= 0 and x % 1 == 0 for x in range(100)]', number=1000000)
5.681200352031738
>>> timeit.timeit('[x >= 0 & x % 1 == 0 for x in range(100)]', number=1000000)
7.641936696134508

What does your PR belong to?

Types of changes

Checklist:

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for any follow-up tasks.