On Mar 8, 5:37 pm, malkarouri <[EMAIL PROTECTED]> wrote: > On Mar 8, 6:24 pm, rockingred <[EMAIL PROTECTED]> wrote: > > > I think it's a bad practice to get into. Did you intend to do the > > "process" step again over the added variables? If not I would set a > > new variable, based on your awful naming convention, let's call it z. > > Then use z.append(y) within the for loop and after you are out of your > > for loop, q.append(z). > > Thanks, rockingred, for the advice. I hope that you didn't assume that > I was a newbie, even if my question looks so. What I was trying to do > is write some Python code which I need to optimize as much as > possible. I am using Cython (Pyrex) and would probably end up > rewriting my whole module in C at one point, but it is really hard to > beat Python data structures at their home turf. So meanwhile, I am > making use of dubious optimizations - on my own responsibility. There > have been a lot of these along the years - like using variables > leaking from list expressions (not anymore). Think of it as a goto. > Yes, I intend to do the process step again over the added variables. > The suggested deque is probably the best, though I need the speed > here. > What are the variable naming you would suggest, for a throwaway - > probably anonymized for the same of publishing on the web - code? > > Cheers, > > Muhammad Alkarouri
If the variables are "throwaways" and will be used in a really small function, then it's probably okay to name them the way you did. I'm just against single character names on principal, because if you need to search a program to find where the variable was used you get too many hits. I prefer to name the variables for what they do. For example, instead of "q" you could use "queue". -- http://mail.python.org/mailman/listinfo/python-list