Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7163 > unrolled thread
| Started by | Carl Banks <pavlovevidence@gmail.com> |
|---|---|
| First post | 2011-06-07 10:08 -0700 |
| Last post | 2011-06-07 14:23 -0600 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
Re: GIL in alternative implementations Carl Banks <pavlovevidence@gmail.com> - 2011-06-07 10:08 -0700
Re: GIL in alternative implementations Ethan Furman <ethan@stoneleaf.us> - 2011-06-07 10:51 -0700
Re: GIL in alternative implementations Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-07 14:22 -0600
Re: GIL in alternative implementations Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-07 14:23 -0600
| From | Carl Banks <pavlovevidence@gmail.com> |
|---|---|
| Date | 2011-06-07 10:08 -0700 |
| Subject | Re: GIL in alternative implementations |
| Message-ID | <7d244fb0-5457-4070-8569-306797f70131@glegroupsg2000goo.googlegroups.com> |
On Monday, June 6, 2011 9:03:55 PM UTC-7, Gabriel Genellina wrote: > En Sat, 28 May 2011 14:05:16 -0300, Steven D'Aprano > <steve+comp....@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. It's main affect performance is that it prevents an optimizer from inlining a function call(which is a good chunk of the payoff you get in languages that can do that). I'm not sure where he gets the idea that this has any impact on concurrency, though. Carl Banks
[toc] | [next] | [standalone]
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2011-06-07 10:51 -0700 |
| Message-ID | <mailman.2540.1307475231.9059.python-list@python.org> |
| In reply to | #7163 |
Carl Banks wrote: > On Monday, June 6, 2011 9:03:55 PM UTC-7, Gabriel Genellina wrote: >> En Sat, 28 May 2011 14:05:16 -0300, Steven D'Aprano >> <steve+comp....@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. > > It's main affect performance is that it prevents an optimizer from inlining a function call(which is a good chunk of the payoff you get in languages that can do that). > > I'm not sure where he gets the idea that this has any impact on concurrency, though. What if f has two calls to self.h() [or some other function], and self.h changes in between? Surely that would be a major headache. ~Ethan~
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2011-06-07 14:22 -0600 |
| Message-ID | <mailman.2545.1307478202.9059.python-list@python.org> |
| In reply to | #7163 |
On Tue, Jun 7, 2011 at 11:51 AM, Ethan Furman <ethan@stoneleaf.us> wrote:
>> I'm not sure where he gets the idea that this has any impact on
>> concurrency, though.
>
> What if f has two calls to self.h() [or some other function], and self.h
> changes in between?
>
> Surely that would be a major headache.
I could imagine a problem similar to the non-atomic increment example
arising from continuations.
from functools import partial
def g(value):
print(value)
return partial(g, value+1)
f = partial(0)
for i in range(10000):
f = f()
With a single thread, this will print the numbers 0 to 9999. With
multiple threads executing the loop simultaneously, not so much. Note
that this is not the same example as the non-atomic increment, because
making "value += 1" atomic would not fix this. You would have to make
the entire function call (and subsequent assignment) atomic to make
this concurrent.
Cheers,
Ian
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2011-06-07 14:23 -0600 |
| Message-ID | <mailman.2546.1307478259.9059.python-list@python.org> |
| In reply to | #7163 |
On Tue, Jun 7, 2011 at 2:22 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote: > from functools import partial > > def g(value): > print(value) > return partial(g, value+1) > > f = partial(0) > for i in range(10000): > f = f() The "partial(0)" should read "partial(g, 0)", of course.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web