Re: [Python-Dev] PEP 289 - Generator Expressions - Let's Move For ward
Guido van Rossum:
My counter to that is that *any* use of genexps where the consumer doesn't consume (or discard) the iterator before the next line is reached is extremely advanced use.
This might be worth putting in the PEP and the docs -- Normal usage of a generator expression is to immediately consume the entire sequence, or to discard the remainder. If portions of a generator *are* used later, programmers may need some extra precautions to ensure that all names still have the desired bindings. -jJ
On Mon, 2004-05-03 at 09:58, Jewett, Jim J wrote:
Guido van Rossum:
My counter to that is that *any* use of genexps where the consumer doesn't consume (or discard) the iterator before the next line is reached is extremely advanced use.
This might be worth putting in the PEP and the docs --
We are in rather dire need of docs and a revised PEP.
Normal usage of a generator expression is to immediately consume the entire sequence, or to discard the remainder.
If portions of a generator *are* used later, programmers may need some extra precautions to ensure that all names still have the desired bindings.
There may be a general rule that functions that make use of free variables are best programmed in a functional style, where the function doesn't depend on side-effects to those variables. Jeremy
Jeremy Hylton wrote:
On Mon, 2004-05-03 at 09:58, Jewett, Jim J wrote:
Guido van Rossum:
My counter to that is that *any* use of genexps where the consumer doesn't consume (or discard) the iterator before the next line is reached is extremely advanced use.
This might be worth putting in the PEP and the docs --
We are in rather dire need of docs and a revised PEP.
Indeed. The timeframe we came up with at PyCon had the generator expressions being landed "in the first week of May". At the moment the discussion seems to be spinning wheels -- it looks (to me) like there's not even 100% agreement from everyone that they should even go into 2.4 at all. I'm not fussed if we slip a week or two here, but if it slips another 6 weeks, say, then the release time line could be in some trouble. -- Anthony Baxter <anthony@interlink.com.au> It's never too late to have a happy childhood.
[Jeremy]
We are in rather dire need of docs and a revised PEP.
[Anthony]
Indeed. The timeframe we came up with at PyCon had the generator expressions being landed "in the first week of May". At the moment the discussion seems to be spinning wheels -- it looks (to me) like there's not even 100% agreement from everyone that they should even go into 2.4 at all.
Well, only one opinion really counts, and the discussion has more the feel of whining at a wake about the deceased's bad qualities <wink>. Alas, the PEP is indeed out of date, and I can't remember exactly which set of gimmicks Guido favored. The PEP currently says early-binding is the rule, but I *think* Guido favored mostly-late binding -- which is late binding, except that the iterable in the leftmost for-clause is evaluated at once. So ... (e1 for stuff in e2 for morestuff in e3 ...) ... is effectively replaced by def __g(primary): for stuff in primary: for morestuff in e3: ... yield e1 ... __g(e2) ...
I'm not fussed if we slip a week or two here, but if it slips another 6 weeks, say, then the release time line could be in some trouble.
Is anyone working (or willing to work) on the PEP, implementation, and docs now? I can't make time for it, but if I could I think the semantic issues are settled (in Guido's mind, and possibly in some email of his I can't find now).
At 17:53 04.05.2004 -0400, Tim Peters wrote:
[Jeremy]
We are in rather dire need of docs and a revised PEP.
[Anthony]
Indeed. The timeframe we came up with at PyCon had the generator expressions being landed "in the first week of May". At the moment the discussion seems to be spinning wheels -- it looks (to me) like there's not even 100% agreement from everyone that they should even go into 2.4 at all.
Well, only one opinion really counts, and the discussion has more the feel of whining at a wake about the deceased's bad qualities <wink>.
well, the fact is that this particular deceased is going to stay with us <wink>
Is anyone working (or willing to work) on the PEP, implementation, and docs now? I can't make time for it, but if I could I think the semantic issues are settled (in Guido's mind, and possibly in some email of his I can't find now).
that's the one (I think) http://mail.python.org/pipermail/python-dev/2004-April/044555.html
Alas, the PEP is indeed out of date, and I can't remember exactly which set of gimmicks Guido favored. The PEP currently says early-binding is the rule, but I *think* Guido favored mostly-late binding -- which is late binding, except that the iterable in the leftmost for-clause is evaluated at once. So
... (e1 for stuff in e2 for morestuff in e3 ...) ...
is effectively replaced by
def __g(primary): for stuff in primary: for morestuff in e3: ... yield e1
... __g(e2) ...
Exactly.
I'm not fussed if we slip a week or two here, but if it slips another 6 weeks, say, then the release time line could be in some trouble.
Is anyone working (or willing to work) on the PEP, implementation, and docs now? I can't make time for it, but if I could I think the semantic issues are settled (in Guido's mind, and possibly in some email of his I can't find now).
How about this one. :-) --Guido van Rossum (home page: http://www.python.org/~guido/)
Indeed. The timeframe we came up with at PyCon had the generator expressions being landed "in the first week of May". At the moment the discussion seems to be spinning wheels -- it looks (to me) like there's not even 100% agreement from everyone that they should even go into 2.4 at all.
There doesn't need to be 100% agreement. This thread (which is indeed getting nowhere) started with my assertion that we should do it, using late binding. I haven't changed my mind yet. I'm still waiting for someone to volunteer to review the code once more and check it in. --Guido van Rossum (home page: http://www.python.org/~guido/)
At 08:28 05.05.2004 -0700, Guido van Rossum wrote:
Indeed. The timeframe we came up with at PyCon had the generator expressions being landed "in the first week of May". At the moment the discussion seems to be spinning wheels -- it looks (to me) like there's not even 100% agreement from everyone that they should even go into 2.4 at all.
There doesn't need to be 100% agreement. This thread (which is indeed getting nowhere)
one likely aspect here is that someone should write the doc for this feature, and consider whether it should be in the tutorial (at least list comprehensions are introduced there), and see how it reads.
started with my assertion that we should do it, using late binding. I haven't changed my mind yet. I'm still waiting for someone to volunteer to review the code once more and check it in.
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/pedronis%40bluewin.ch
Guido van Rossum wrote:
There doesn't need to be 100% agreement. This thread (which is indeed getting nowhere) started with my assertion that we should do it, using late binding. I haven't changed my mind yet. I'm still waiting for someone to volunteer to review the code once more and check it in.
Sure. And this was what I was referring to. Lotsa noise, little traction. <wink> This isn't meant as a slap at anyone - I am quite aware of time limitations. I guess I was hoping to prod someone into stepping forward and doing the work. Anthony -- Anthony Baxter <anthony@interlink.com.au> It's never too late to have a happy childhood.
Hello, On Wed, May 05, 2004 at 08:28:35AM -0700, Guido van Rossum wrote:
There doesn't need to be 100% agreement. This thread (which is indeed getting nowhere)
I'll leave it alone, then. It can't go anywhere as long as we'll keep opposing a bunch of concrete examples and an intuition. I retract because your intuition is firmly grounded, and I respect that even if I disagree -- I, for example, have the intuition that high-level languages should be faster than low-level ones, despite all the examples :-) Armin
There may be a general rule that functions that make use of free variables are best programmed in a functional style, where the function doesn't depend on side-effects to those variables.
The troublesome cases tend to be ones where the function depends on *the lack* of side effects to free variables.
participants (8)
-
Andrew Koenig -
Anthony Baxter -
Armin Rigo -
Guido van Rossum -
Jeremy Hylton -
Jewett, Jim J -
Samuele Pedroni -
Tim Peters