Generators vs. Functions?



Hello,

in <dr86uc$8kt$1@xxxxxxxxxxxxxx>, Magnus Lycka <lycka@xxxxxxxxx> 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 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 future or is this a matter of
principle and will consequently remain like this forever?

TIA,

Sincerely,

Wolfgang Keller

.



Relevant Pages

  • Re: What is executed when in a generator
    ... semantics of generators? ... The difference under the bonnet is that calling the generator has less overheads, as it is not a true function call - stack frames etc are not having to be set up fully. ...
    (comp.lang.python)
  • Re: Random number (1,2,3)
    ... I was calling the function once. ... Raymond Martineau wrote: ... I'm trying create a random number generator, ... int no_goal, rand_Number; ...
    (comp.lang.c)
  • Re: PEP 288 ponderings
    ... >>setting a generator attribute and calling the generator's next function, ... result of calling .nexton the generator object. ... I wonder if maybe it would be worth moving this part to a separate PEP. ...
    (comp.lang.python)
  • Re: Random number (1,2,3)
    ... I'm trying create a random number generator, ... int no_goal, rand_Number; ... The problem may be, if you are calling it only once per program invocation, ...
    (comp.lang.c)
  • Re: Python code written in 1998, how to improve/change it?
    ... resuming a generator causes less overhead than the ... I'm just a poor scripting dilettant who's asking questions. ...
    (comp.lang.python)