<div class="gmail_quote">On 6 September 2012 16:34, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve+comp.lang.python@pearwood.info" target="_blank">steve+comp.lang.python@pearwood.info</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, 06 Sep 2012 00:34:56 +0000, Antoine Pitrou wrote:<br>
> Monkey-patching globals is not thread-safe: other threads will see your</div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
> modification, which is risky and fragile.<br>
<br>
</div>Isn't that assuming that you don't intend the other threads to see the<br>
modification?<br>
<br>
If I have two functions in my module that call "open", and I monkey-patch<br>
the global (module-level) name "open" to intercept that call, I don't see<br>
that there is more risk of breakage just because one function is called<br>
from a thread.<br>
<br>
Obviously monkey-patching the builtin module itself is much riskier,<br>
because it doesn't just effect code in my module, it affects *everything*.</blockquote><div><br></div><div>It's not as though the option to monkey-patch has been taken away. But hopefully there is now less of a need for it.</div>
<div><br></div><div>Tim Delaney </div></div>