Sincesys._getframe().f_back.f_lineno
does not work at all in python 3.9, following could be used from now:
from inspect import currentframe
def testLineNumberFunction() -> int:
return currentframe().f_back.f_lineno
print(f'line number is {testLineNumberFunction()}')
Result:
line number is 8
Is there a faster way to achieve this ?
Because the library inspect seems to be slow as mentioned here by @AlexGranovsky