Closed
Description
Code Sample, a copy-pastable example if possible
While going through the code I observed at couple of places where bool(o)
is being used to check whether the object o
is None
.
Example 1:
Line 449 in 6620dc6
Example 2:
Line 821 in 6620dc6
Problem description
bool(o)
is several times slower than o is not None
(see below). In the above cases however, majority of the time indeed is being taken by the re.search
and therefore it might not matter for the overall time. But, why not switch to the possibly correct version?
Moreover, the functionality remains the same as re.search
and re.match
return None
when they cannot find a match; which is fundamentally what is being checked in this code.