On Fri, Jul 11, 2008 at 12:00 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > From: "Guido van Rossum" <[EMAIL PROTECTED]> >> >> The new failure in 3.0 is a side effect of the translation (mostly) of >> list comps into genexps. The underlying problem is that the genexp >> creates a function scope, and function scopes don't have access to the >> surrounding class body scope. (There's a really good but extremely >> subtle reason for that.) > > Would you be open to an alternate implementation for list/set/dict comps > that doesn't use a genexps? That would solve the scope problem, the > performance hit, and make tracing more straight-forward.
Well, the problem is that we specifically decided that the difference between listcomps and genexps is a source of problems and confusion, and that consequently a listcomp [<genexp>] should be implemented as completely equivalent to list(<genexp>). I'd be happy to see a solution that implements genexps more efficiently without changes in semantics (and then listcomps would also benefit). > If you're open to it, I can see if the EuroPython sprinters can find an > implementation closer to what we had before but using the compiler to create > an invisible induction variable. > > Not sure if the current implementation was really a winning trade. It may > have been better to have the minor but easy to explain nuisance > of exposing the induction variable instead of having the harder-to-explain > subtleties associated with a slower underlying genexp. No, based on feedback over the years the exposure of the induction variable is a real problem that needs to be rooted out. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ 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