En Sun, 18 Nov 2007 22:24:39 -0300, greg <[EMAIL PROTECTED]> escribi�:
> Importing the names from tokenize that you use repeatedly > should save some time, too. >from tokenize import STRING, NUMBER > > If you were willing to indulge in some default-argument abuse, you > could also do > > def atom(next, token, STRING = tokenize.STRING, NUMBER = > tokenize.NUMBER): > ... > > A more disciplined way would be to wrap it in a closure: > > def make_atom(): > from tokenize import STRING, NUMBER > def atom(next, token): > ... > return atom ...but unfortunately it's the slowest alternative, so wouldn't count as a speed optimization. I would investigate a mixed approach: using a parser to ensure the expression is "safe", then calling eval. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list