On Sun, 05 Feb 2006 19:14:29 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>On Sun, 05 Feb 2006 03:31:24 +, Neil Schemenauer wrote:
>
>> Peter Hansen <[EMAIL PROTECTED]> wrote:
>>> More precisely, the state of the function is *saved* when a yield
>>> occurs, so you certainly don't *recrea
Duncan Booth wrote:
> Steven D'Aprano wrote:
>>So on the basis of my tests, there is a small, but significant speed
>>advantage to _calling_ a function versus _resuming_ a generator.
>
> I get the same, but the difference is much less on my system:
With Python 2.4? Doesn't surprise me a bit.
I t
On Sun, 05 Feb 2006 16:14:54 +, Neil Schemenauer wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>> Have you actually measured this, or are you just making a wild
>> guess?
>
> I haven't timed it until now but my guess it not so wild. I'm
> pretty familiar with the generator implementati
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> Have you actually measured this, or are you just making a wild
> guess?
I haven't timed it until now but my guess it not so wild. I'm
pretty familiar with the generator implementation (having written
the initial version of it). In Python 2.3, resuming
On Sun, 05 Feb 2006 09:49:21 +0100, Fredrik Lundh wrote:
> Steven D'Aprano wrote:
>
>> So on the basis of my tests, there is a small, but significant speed
>> advantage to _calling_ a function versus _resuming_ a generator.
>
> now add state handling to your micro-benchmark, and see if the funct
Steven D'Aprano wrote:
t1.timeit()
> 0.63980388641357422
...
t2.timeit()
> 0.82081794738769531
>
> So on the basis of my tests, there is a small, but significant speed
> advantage to _calling_ a function versus _resuming_ a generator.
I get the same, but the difference is much less on
Steven D'Aprano wrote:
> So on the basis of my tests, there is a small, but significant speed
> advantage to _calling_ a function versus _resuming_ a generator.
now add state handling to your micro-benchmark, and see if the function
example still runs faster.
(hint: functions and generators do d
On Sun, 05 Feb 2006 03:31:24 +, Neil Schemenauer wrote:
> Peter Hansen <[EMAIL PROTECTED]> wrote:
>> More precisely, the state of the function is *saved* when a yield
>> occurs, so you certainly don't *recreate* it from scratch, but merely
>> restore the state, and this should definitely be
Peter Hansen <[EMAIL PROTECTED]> wrote:
> More precisely, the state of the function is *saved* when a yield
> occurs, so you certainly don't *recreate* it from scratch, but merely
> restore the state, and this should definitely be faster than creating it
> from scratch in the first place.
Right
Joseph Garvin wrote:
> Wolfgang Keller wrote:
>>If this is actually also true in the general case, and not due to eventual
>>non-representativeness of the test mentioned above, is it simply due to a
>>less-than-optimum implementation of generators in the current Pyython
>>interpreter and thus li
Joseph Garvin wrote:
>
> I am not a CPython or PyPy hacker, but I would guess that it will always
> be slower as a matter of principal. When resuming a generator you have
> to resetup the state the function was in when it was last called, which
> I think should always be more costly than callin
Wolfgang Keller wrote:
>If this is actually also true in the general case, and not due to eventual
>non-representativeness of the test mentioned above, is it simply due to a
>less-than-optimum implementation of generators in the current Pyython
>interpreter and thus likely to change in the futu
Hello,
in <[EMAIL PROTECTED]>, Magnus Lycka <[EMAIL PROTECTED]> posts the
result of a short test that seems to indicate that resuming a generator takes
more time than calling a function.
If this is actually also true in the general case, and not due to eventual
non-representativeness of the te
13 matches
Mail list logo