You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The call to `ord()` and the list comprehension both showed up in my profiler.
Some observations:
- The call to `ord()` doesn't need to happen every iteration of that list comprehension.
- A list isn't necessary, we can stop searching once we've found a hit.
- The list is sorted, so we can be sure that if a char is lower than the upper bound of a group, we don't need to evaluate any of the higher ranges.
- Technically we could also do a binary search instead of a linear one, but I'm assuming that, overall, most chars will be in the lowest ranges (ascii) and the loop will abort on its first iteration.
0 commit comments