Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize a set() in code to be compiled as pypy's rpython?

I want to compile some python code using pypy's rpython translator. A very simple toy example that doesn't do anything :

def main(argv):
 a = []
 b = set(a)
 print b
 return 0

def target(driver,args):
        return main,None

If I compile it as:

python2.6 ~/Downloads/pypy-1.4.1-src/pypy/translator/goal/translate.py --output trypy trypy.py 

It doesn't compile, rather just halts with errors something like this:

[translation:ERROR]  AttributeError': 'FrozenDesc' object has no attribute 'rowkey'
[translation:ERROR]  .. v1 = simple_call((type set), v0)
[translation:ERROR]  .. '(trypy:3)main'
[translation:ERROR] Processing block:
[translation:ERROR]  block@0 is a <class 'pypy.objspace.flow.flowcontext.SpamBlock'>
[translation:ERROR]  in (trypy:3)main
[translation:ERROR]  containing the following operations:
[translation:ERROR]        v0 = newlist()
[translation:ERROR]        v1 = simple_call((type set), v0)
[translation:ERROR]        v2 = str(v1)
[translation:ERROR]        v3 = simple_call((function rpython_print_item), v2)
[translation:ERROR]        v4 = simple_call((function rpython_print_newline))
[translation:ERROR]  --end--

If I take out the set() function it works. How do you use sets in rpython?

like image 855
highBandWidth Avatar asked Jan 19 '11 21:01

highBandWidth


1 Answers

So its official, set() is not supported in rpython. Thanks TryPyPy.

like image 109
highBandWidth Avatar answered Nov 20 '22 13:11

highBandWidth