demoting method, cannot follow, call result degenerated
![](https://secure.gravatar.com/avatar/0a8e8de28b748c5db6e1fae0fb5a57ee.jpg?s=120&d=mm&r=g)
I'm still struggling to learn all the rules of RPython, i have read the coding guide, and the PDF's PyGirl and Ancona's RPython paper, but still i feel i'm not fully grasping everything. I have a function that returns different classes that all share a common base class. It works until i introduce a new subclass that has some methods of the same name. Then i get the demotion, can not follow, degenerated error. I googled, but all i can find is an IRC log where Fijal seems to taking talking about my problem. http://www.tismer.com/pypy/irc-logs/pypy/%23pypy.log.20070125 <fijal> pedronis: if function can return (in rpython) set of classes with common superclass, than all methods that I call later must be defined on that superclass, right? [11:30] <fijal> [15:01] <pedronis> yes, unless you assert a specific subclass So i just need to use an assert statement before the function return, and assert the class i am returning? I am blogging about my progress while learning RPython, i have posted about meta-programming in Rpython which is a new concept to me. http://pyppet.blogspot.com/2010/08/meta-programming-in-rpython.html -brett
![](https://secure.gravatar.com/avatar/bfc96d2a02d9113edb992eb96c205c5a.jpg?s=120&d=mm&r=g)
Hey. If at any place in code you want to call methods on a thing that can't be proven to be of a specific subclass, they have to be defined on a superclass (even dummy versions). If you are however sure that this object will be of a specific subclass, write: assert isinstance(x, MySubclass) x.specific_method that's fine On Wed, Aug 4, 2010 at 10:21 AM, Hart's Antler <bhartsho@yahoo.com> wrote:
I'm still struggling to learn all the rules of RPython, i have read the coding guide, and the PDF's PyGirl and Ancona's RPython paper, but still i feel i'm not fully grasping everything.
I have a function that returns different classes that all share a common base class. It works until i introduce a new subclass that has some methods of the same name. Then i get the demotion, can not follow, degenerated error.
I googled, but all i can find is an IRC log where Fijal seems to taking talking about my problem. http://www.tismer.com/pypy/irc-logs/pypy/%23pypy.log.20070125
<fijal> pedronis: if function can return (in rpython) set of classes with common superclass, than all methods that I call later must be defined on that superclass, right?
[11:30] <fijal> [15:01] <pedronis> yes, unless you assert a specific subclass
So i just need to use an assert statement before the function return, and assert the class i am returning?
I am blogging about my progress while learning RPython, i have posted about meta-programming in Rpython which is a new concept to me.
http://pyppet.blogspot.com/2010/08/meta-programming-in-rpython.html
-brett
_______________________________________________ pypy-dev@codespeak.net http://codespeak.net/mailman/listinfo/pypy-dev
![](https://secure.gravatar.com/avatar/0a8e8de28b748c5db6e1fae0fb5a57ee.jpg?s=120&d=mm&r=g)
Thanks for clarifying Fijal, putting dummy functions on the base class fixes the demotion errors. But now i have a new problem, from the bookkeeper, unpackiterable. pypy.annotation.bookkeeper.CallPatternTooComplex': '*' argument must be SomeTuple .. v2 = call_args(v0, ((0, (), True, False)), v1) .. '(rbpy:1)BPY_Object_MESH.GET_location' I checked the object, instead of SomeTuple it is SomeObject. I'm trying to understand what causes the CallPatternTooComplex error, i can not reproduce it with a simple model that is close to what my actual code is doing. class T(object): def hi( self, *args ): pass class TA( T ): def hi( self, a,b,c ): pass class TB( T ): def hi( self, y ): pass def pypy_entrypoint(): t = T() ta = TA() tb = TB() ta.hi(1,2,'x') tb.hi() tb.hi('xxx') print 'too complex test' the above translates just fine, no TooComplex error. -brett --- On Wed, 8/4/10, Maciej Fijalkowski <fijall@gmail.com> wrote:
From: Maciej Fijalkowski <fijall@gmail.com> Subject: Re: [pypy-dev] demoting method, cannot follow, call result degenerated To: "Hart's Antler" <bhartsho@yahoo.com> Cc: pypy-dev@codespeak.net Date: Wednesday, 4 August, 2010, 1:25 AM Hey.
If at any place in code you want to call methods on a thing that can't be proven to be of a specific subclass, they have to be defined on a superclass (even dummy versions).
If you are however sure that this object will be of a specific subclass, write: assert isinstance(x, MySubclass) x.specific_method
that's fine
On Wed, Aug 4, 2010 at 10:21 AM, Hart's Antler <bhartsho@yahoo.com> wrote:
I'm still struggling to learn all the rules of RPython, i have read the coding guide, and the PDF's PyGirl and Ancona's RPython paper, but still i feel i'm not fully grasping everything.
I have a function that returns different classes that all share a common base class. It works until i introduce a new subclass that has some methods of the same name. Then i get the demotion, can not follow, degenerated error.
I googled, but all i can find is an IRC log where Fijal seems to taking talking about my problem. http://www.tismer.com/pypy/irc-logs/pypy/%23pypy.log.20070125
<fijal> pedronis: if function can return (in rpython) set of classes with common superclass, than all methods that I call later must be defined on that superclass, right?
[11:30] <fijal> [15:01] <pedronis> yes, unless you assert a specific subclass
So i just need to use an assert statement before the function return, and assert the class i am returning?
I am blogging about my progress while learning RPython, i have posted about meta-programming in Rpython which is a new concept to me.
http://pyppet.blogspot.com/2010/08/meta-programming-in-rpython.html
-brett
_______________________________________________ pypy-dev@codespeak.net http://codespeak.net/mailman/listinfo/pypy-dev
participants (2)
-
Hart's Antler
-
Maciej Fijalkowski