Finally, after a lot of head-banging, I found a way to avoid calling ord[]
, which, apparently, is very expensive. Below is the test code and results:
from timeit import timeit
from itertools import count
from string import ascii_lowercase
def alphabet_position_Headcrab[text]:
nums = [str[ord[x] - 96] for x in text.lower[] if x >= 'a' and x