Since Python is a scripted language does the length of variable names within a program affect speed? Or are the names replaced by symbols when the program is loaded?
The names are used at runtime as keys in a dict. Short of using a variable name with 5893839278487 letters in it, you're not going to notice any difference with shorter names. You will save far more developer time (worth a lot more than CPU time) by using clear, descriptive variable and function names.
Don't let that stop you from using "i" as a loop variable though, but for loops longer than a couple lines you might consider iTech or iPlayer or something similar. It sucks trying to remember which is which when you've used both "i" and "j" in the same block of code.
Thanks.
I do use relatively long descriptive names, and was wondering what kind of impact it might have. It sounds like I should keep the names to a reasonable length.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.