rpython questions, **kw, __call__, __getattr__

Looking through the pypy source code i see **kw, __call__ and __getattr__ are used, but when i try to write my own rpython code that uses these conventions, i get translation errors. Do i need to borrow from "application space" in order to do this or can i just give hints to the annotator? Thanks, -brett #this is allowed def func(*args): print(args) #but this is not? def func(**kw): print(args) #error call pattern too complex #this class fails to translate, are we not allowed to define our own __call__ and __getattr__ in rpython? class A(object): __call__(*args): print(args) __getattr__(self,name): print(name)

Hello. __call__ and __getattr__ won't work. You see it in pypy source code, because not all of pypy source code is RPython (in fact, Python is a metaprogramming language for RPython). Same goes to **kw. On Fri, Jul 23, 2010 at 6:49 AM, Hart's Antler <bhartsho@yahoo.com> wrote:
Looking through the pypy source code i see **kw, __call__ and __getattr__ are used, but when i try to write my own rpython code that uses these conventions, i get translation errors. Do i need to borrow from "application space" in order to do this or can i just give hints to the annotator? Thanks, -brett
#this is allowed def func(*args): print(args)
#but this is not? def func(**kw): print(args) #error call pattern too complex
#this class fails to translate, are we not allowed to define our own __call__ and __getattr__ in rpython? class A(object): __call__(*args): print(args) __getattr__(self,name): print(name)
_______________________________________________ pypy-dev@codespeak.net http://codespeak.net/mailman/listinfo/pypy-dev

On 07/23/2010 06:49 AM, Hart's Antler wrote:
Looking through the pypy source code i see **kw, __call__ and __getattr__ are used,
Where exactly are they used? Not all of the code in PyPy is RPython.
but when i try to write my own rpython code that uses these conventions, i get translation errors. Do i need to borrow from "application space" in order to do this or can i just give hints to the annotator? Thanks, -brett
#this is allowed def func(*args): print(args)
#but this is not? def func(**kw): print(args) #error call pattern too complex
#this class fails to translate, are we not allowed to define our own __call__ and __getattr__ in rpython?
class A(object): __call__(*args): print(args) __getattr__(self,name): print(name)
You cannot use any __xxx__ functions in RPython, only __init__ and __del__. Anyway, you cannot translate a class, so "fails to translate" has no meaning :-). Cheers, Carl Friedrich
participants (3)
-
Carl Friedrich Bolz
-
Hart's Antler
-
Maciej Fijalkowski