Modifying Interpreter-level Object from Application

Hi, At the application level, I want to modify some interpreter-level attributes of an object. Right now, I have the interpreter level functions that allow me to modify the interpreter object. Is the easiest way to have an application access interpreter level attributes to use a Mixed Module with interpreter level definitions? I'm having a bit of trouble getting it to work, so I was wondering if there was a much easier way for an application to modify interpreter objects or call interpreter level functions that modify an object. Thanks, Frank

Hi Frank, no, unfortunately there's not really a shortcut to exposing the methods, functions and attributes via a mixed module, because you need to think about the semantics of parameter type and result conversion for every such function anyway. Do you have trouble to get it to work at all? Or is it just tedious? If the former, there are some hints about mixed modules here: http://doc.pypy.org/en/latest/coding-guide.html#implementing-a-mixed-interpr... For the latter, if you need to do this for absolutely *every* interpreter level attribute, there may be a way to achieve this effect with some magic meta-programming, though I'd have to think a bit how. Cheers, Carl Friedrich On 27/01/17 16:45, Frank Wang wrote:

Hi Carl, Thanks for the information! I just have to do it for a specific attribute. It is just a bit tedious as you said, making sure the semantics of the parameter type and result conversion work properly is a bit tricky. Frank On Fri, Jan 27, 2017 at 11:35 AM, Carl Friedrich Bolz <cfbolz@gmx.de> wrote:

Hi, Is there a way to distinguish in a mixed module function, e.g. len, whether the function is being called from the application or interpreter? Right now, I'm modifying len to print out information about an interpreter level object, but I only want it to print out when it's being called by an application. Thanks, Frank On Fri, Jan 27, 2017 at 12:40 PM, Frank Wang <frankw@mit.edu> wrote:

Hi Frank, no, unfortunately there's not really a shortcut to exposing the methods, functions and attributes via a mixed module, because you need to think about the semantics of parameter type and result conversion for every such function anyway. Do you have trouble to get it to work at all? Or is it just tedious? If the former, there are some hints about mixed modules here: http://doc.pypy.org/en/latest/coding-guide.html#implementing-a-mixed-interpr... For the latter, if you need to do this for absolutely *every* interpreter level attribute, there may be a way to achieve this effect with some magic meta-programming, though I'd have to think a bit how. Cheers, Carl Friedrich On 27/01/17 16:45, Frank Wang wrote:

Hi Carl, Thanks for the information! I just have to do it for a specific attribute. It is just a bit tedious as you said, making sure the semantics of the parameter type and result conversion work properly is a bit tricky. Frank On Fri, Jan 27, 2017 at 11:35 AM, Carl Friedrich Bolz <cfbolz@gmx.de> wrote:

Hi, Is there a way to distinguish in a mixed module function, e.g. len, whether the function is being called from the application or interpreter? Right now, I'm modifying len to print out information about an interpreter level object, but I only want it to print out when it's being called by an application. Thanks, Frank On Fri, Jan 27, 2017 at 12:40 PM, Frank Wang <frankw@mit.edu> wrote:
participants (3)
-
Armin Rigo
-
Carl Friedrich Bolz
-
Frank Wang