[Python-3000] Set literals (original) (raw)
Georg Brandl g.brandl at gmx.net
Mon Aug 28 22:32:53 CEST 2006
- Previous message: [Python-3000] Set literals
- Next message: [Python-3000] Set literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum wrote:
> However you might be able to just cleanup the grammar so they are > identical, that would be simpler I suspect.
Looking at the grammar, there's only testlistsafe left to kill, in favor of ortest like in generator expressions. The old rules are still needed. Hm, it's been so long... Why?
In listcomps/genexps, old_test and old_lambdef do not allow conditional expressions in order to avoid confusion with the loop's "if".
Hm. Is the precedence in
x = lambda: 1 if 0 else 2 really obvious? Yes if you think about how you would use it. Conditionally returning a lambda or something else is kind of rare. A lambda using a condition is kind of useful. :-)
Okay, that makes sense.
>> * list comprehensions are special-cased because of the LISTAPPEND opcode. >> If there isn't going to be a special-cased SETADD, it's probably the >> easiest thing to transform {x for x in a} into set(x for x in a) in the >> AST step, with "set" of course always being the builtin set. > > Right. That might actually become a prototype for how to the list > translation as well.
Would this need a new opcode, or should generators be special-cased by BUILDSET? Can't remember what BUILDSET is.
Sorry... it's the newly introduced opcode that creates a new set.
Georg
- Previous message: [Python-3000] Set literals
- Next message: [Python-3000] Set literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]