Quick question about CPython interpreter

DFS nospam at dfs.com
Fri Oct 14 18:25:23 EDT 2022


---------------------------------------------------------------------
this does a str() conversion in the loop
---------------------------------------------------------------------
for i in range(cells.count()):
   if text == str(ID):
     break


---------------------------------------------------------
this does one str() conversion before the loop
---------------------------------------------------------
strID = str(ID)
for i in range(cells.count()):
   if text == strID:
     break


But does CPython interpret the str() conversion away and essentially do 
it for me in the first example?




More information about the Python-list mailing list