Length of variable names in Python

General Tso

Panzer General
Joined
Oct 12, 2007
Messages
1,547
Location
U. S. of A.
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. :mad:
 
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.
 
Top Bottom