So it's not possible for RPython to call regular, non-RPython? Is there some wrapper I could write to let RPython call regular python code? Best, Martin Simon Burton wrote:
On Fri, 25 Jan 2008 10:30:17 -0500 "Martin C. Martin" <martin@martincmartin.com> wrote:
Hi,
I'm really impressed with the C code generated for some functions I'd like to use in my project. You guys rock!
I've run into two problems this morning. In pypy-1.0.0, this:
import re import os, sys from pypy.translator.interactive import Translation import py
def mytest(): x = re.search('bar', 'foobar') return x.start()
t = Translation(mytest) t.annotate()
throws an exception:
File "/ita/downloaded/pypy-1.0.0/pypy/annotation/unaryop.py", line 567, in simple_call return bltn.analyser(bltn.s_self, *args) File "/ita/downloaded/pypy-1.0.0/pypy/tool/instancemethod.py", line 19, in __call__ return self.im_func(firstarg, *args, **kwds) TypeError': method_get() takes exactly 3 arguments (2 given) .. v1 = simple_call((builtin_function_or_method get), v0) .. '(sre:213)_compile_star2'
This is an InstanceMethod where im_self is a SomeDict and args is a tuple with a single element, a SomeTuple whose "const" is (<type 'str'>, 'bar', 0) and whose "items" is (SomeObject, SomeString, SomeInteger). It seems to be calling a method_get() with two args, SomeDict and SomeTuple, whereas it wants 3. Any idea how to fix this?
I'm not sure you can use module "re" in rpython code.
The error is because somewhere there is a .get(XX) method call on a dict. In rpython the default arg for dict.get must be specified.
Simon.
Martin C. Martin wrote:
So it's not possible for RPython to call regular, non-RPython? Is there some wrapper I could write to let RPython call regular python code?
Not easily. You can call normal python code, provided that you run pypy interpreter, not cpython. This means that stuff like re are working, but stuff like pygtk or any 3rd party modules doesn't. Also calling is very different. You can take a look at module/_demo if you like, but there are obstacles, like you cannot compile only your module, you need each time to compile whole interpreter (which takes ~30minutes on decent machine). It's very unlikely you want to use it that way :) :.
Maciek Fijalkowski wrote:
Martin C. Martin wrote:
So it's not possible for RPython to call regular, non-RPython? Is there some wrapper I could write to let RPython call regular python code?
Not easily. You can call normal python code, provided that you run pypy interpreter, not cpython. This means that stuff like re are working, but stuff like pygtk or any 3rd party modules doesn't.
Also calling is very different. You can take a look at module/_demo if you like, but there are obstacles, like you cannot compile only your module, you need each time to compile whole interpreter (which takes ~30minutes on decent machine). It's very unlikely you want to use it that way :)
:) Ok, thanks. Best, Martin
participants (2)
-
Maciek Fijalkowski
-
Martin C. Martin