[Python-3000] sets in P3K? (original) (raw)

Eli Stevens (WG.c) listsub at wickedgrey.com
Fri Apr 28 01:05:13 CEST 2006


Barry Warsaw wrote:

Okay, radical/insane/heretical question time: do we really need literal tuple syntax? IOW, what if (1, 2, 3) created a frozenset instead of a tuple?

Or perhaps an even stupider idea: what if the compiler could recognize certain use cases and generate different types depending on how the object is used.

I think you'd have to create a tuple, and convert it to a set on the fly. Which should x be in the following:

x = (1, 2, 1) dictOfCallables"foo"

My gut feeling is that you'd need to have PyPy's RPython to even begin taking a guess (and AFAIK, the above isn't valid RPython).

So, again, what if (...) created a set/frozen set instead of a tuple? It's py3k, so broken code be damned. :)

How would you have the following code be written? I'm curious what the syntax transformation would be.

a = (3,0) b = (0,4) c = (3,4) def addpoint(a, b): ... return (a[0] + b[0], a[1] + b[1]) ... tri[a] = "a" tri[b] = "b" tri[c] = "c" assert tri[addpoint(a, b)] == "c"

put-down-that-pitchfork-ly y'rs, -Barry

just-long-enough-to-light-my-torch-ly y'rs, ;) Eli



More information about the Python-3000 mailing list