[Python-3000] Set literal

Christian Heimes lists at cheimes.de
Thu Jan 31 00:42:40 CET 2008


Greg Ewing wrote:
> Do you really want set comprehensions at all, given that
> set(genexp) exists?

For me comprehension are a means to optimize common patterns in the
sense of faster to execute, faster to read and faster to write. Do set
comprehensions occur so often that {item for item in sequence} makes
code both faster and more readable? Or is the speed benefit of a frozen
set literal larger?

Personally I'm more than happy to trade set comprehensions for optimized
frozen set literals. My code has more 'item in fixed_set' than sets. I
can't remember a project where I've used frozenset() instead of a tuple.
 The name is too long.

Christian



More information about the Python-3000 mailing list