GIL in alternative implementations

Jean-Paul Calderone calderone.jeanpaul at gmail.com
Tue Jun 7 08:07:03 EDT 2011


On Jun 7, 12:03 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
wrote:
> En Sat, 28 May 2011 14:05:16 -0300, Steven D'Aprano  
> <steve+comp.lang.pyt... at pearwood.info> escribi :
>
>
>
>
>
>
>
>
>
> > On Sat, 28 May 2011 09:39:08 -0700, John Nagle wrote:
>
> >> Python allows patching code while the code is executing.
>
> > Can you give an example of what you mean by this?
>
> > If I have a function:
>
> > def f(a, b):
> >     c = a + b
> >     d = c*3
> >     return "hello world"*d
>
> > how would I patch this function while it is executing?
>
> I think John Nagle was thinking about rebinding names:
>
> def f(self, a, b):
>    while b>0:
>      b = g(b)
>      c = a + b
>      d = self.h(c*3)
>    return "hello world"*d
>
> both g and self.h may change its meaning from one iteration to the next,  
> so a complete name lookup is required at each iteration. This is very  
> useful sometimes, but affects performance a lot.
>

And even the original example, with only + and * can have side-
effects.  Who knows how a defines __add__?

Jean-Paul



More information about the Python-list mailing list