<br><div><span class="gmail_quote">On 4/12/06, <b class="gmail_sendername">"Martin v. Löwis"</b> <<a href="mailto:martin@v.loewis.de">martin@v.loewis.de</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thomas Wouters wrote:<br>> In fact... perhaps module functions should then get the module object as<br>> the first argument (currently unused but always defined)?<br><br>That wouldn't work: the first argument currently *is* used, atleast
<br>if you pass a non-NULL value for self to Py_InitModule4. Of course,<br>we could drop that in Py3k, and declare that you always get the module<br>object.</blockquote><div><br>Right, forgot about that. I've never seen anyone use it, though.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">However, that still wouldn't fully work, since you might need access<br>to module objects in a method of a type you implemented, where self
<br>is the object. So I think you need some way to go through the current<br>interpreter.</blockquote><div><br>Well, I said that, it just wasn't part of what you quoted: "Then we just need conceptually-new magic to fetch the right module
object when dealing with methods of types defined in the module (which,
I believe, should be pretty rare.)" Your point about importing a module the second time in the same interpreter (by removing it from sys.modules, or by using reload()) also requires this. We'd need a convenient way to do that (I'm not sure I consider casting the result of PyObject_GetAttrString(self, "__module__") 'convenient'), and we'd need to educate all extension writers (including the ones working on CPython proper) when to use the module object instead of direct C variable access. Using a C global instead of a module object attribute would lead to subtle bugs in subtle cases, like when multiple interpreters are involved. Maybe, when we're done, we should be running regrtest in multiple interpreters concurrently, too. ;P
<br><br>I do think it's worth it, though.<br></div></div><br>-- <br>Thomas Wouters <<a href="mailto:thomas@python.org">thomas@python.org</a>><br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!