[Python-Dev] Re: native code compiler? (or, OCaml vs. Python)
Jeremy Hylton
jeremy@zope.com (Jeremy Hylton)
Mon, 3 Feb 2003 17:38:47 -0500
>>>>> "BAW" == Barry A Warsaw <barry@python.org> writes:
>>>>> "JH" == Jeremy Hylton <jeremy@zope.com> writes:
JH> On many occasions I have externally patched a module's namespace
JH> for debugging. It's been really convenient to replace some
JH> function with a wrapper that does some logging or updates a
JH> table tracking currently used resources. I've done the same
JH> with builtin open/file. As you noted, it seems less useful to
JH> override other builtins for this purpose.
BAW> I've done the same, and when I've needed, it's been incredibly
BAW> handy. Rare, but useful. Then again, I've also only done this
BAW> with open(), so maybe something like an open() hook would
BAW> suffice. I can imagine some of the other built-ins /might/ be
BAW> useful to debuggingly replace, but that's just speculation on
BAW> my part, and may be yagni.
But it is useful for to replace modules. For example, if you want to
debug a module that uses the thread module, you can replace it's
"thread" global with something that hooks "start_new_thread." I think
that pattern is not uncommon.
Jeremy