Raymond Hettinger <[EMAIL PROTECTED]> writes: > Good question. To see the answer, look at a code tranformation from: > > if file_ext.lower() in set(['html', 'xml', 'xhtml']): > handle(filename) > > into: > > > if file_ext.lower() in {'html', 'xml', 'xhtml'}: > handle(filename)
Beware that without optimization this: if file_ext.lower() in ['html', 'xml', 'xhtml']: handle(filename) is probably faster than this: if file_ext.lower() in {'html', 'xml', 'xhtml'}: handle(filename) and with some trivial optimization this: if file_ext.lower() in ('html', 'xml', 'xhtml'): handle(filename) is even faster (the tuple can be allocated statically). So from the efficiency point of view using sets in such cases is a loss. And I'm not sure that optimizing 'x in {a,b,c}' to comparisons would be justified: it gives different results if some of a,b,c are not hashable. -- __("< Marcin Kowalczyk \__/ [EMAIL PROTECTED] ^^ http://qrnik.knm.org.pl/~qrczak/ _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com