On Mon, 11 Jan 2010 18:57:09 +0000, MRAB wrote: > There's nothing wrong with building dicts or other lookup tables outside > a function in order to avoid re-creating them every time the function is > called.
Actually there is, but the benefit (avoiding the re-creation of the table) may be worth the cost (loss of encapsulation due to the use of a global variable). Also, it is slightly slower to access a global than to access a local. This truly is a micro-optimization, and won't matter one bit for most functions, but in some rare cases it may. But these are just quibbles. In general, I would agree with you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list