Closed jdufresne closed 5 years ago
The new form:
range()
try
except
None
The new version is also slightly faster. Running the function through Python's timeit showed the following results:
timeit
old: 0.6434267910080962 new: 0.40665965899825096
Coverage decreased (-0.005%) to 97.596% when pulling 2af6462b438f5f8971472cbdf1346ec2b93b4e8d on jdufresne:simplify into 3697acd58137bec34ef7dc812f69f3b14990a9bb on Alir3z4:master.
The new form:
range()
call. On Python 2 this avoids building the data structure in memory.try
/except
block. The comparison is required either way, so just do that from the start.None
.The new version is also slightly faster. Running the function through Python's
timeit
showed the following results:old: 0.6434267910080962 new: 0.40665965899825096