<br>Hi Elefterios.<br><br>I don't really work on PyPy, but I've written code that runs on PyPy and CPython 2&3 and Jython, unmodified. I tried IronPython too, but it was too different from the others.<br><br><div class="gmail_quote">
On Sat, May 7, 2011 at 6:13 PM, Elefterios Stamatogiannakis <span dir="ltr"><<a href="mailto:estama@gmail.com">estama@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi all, and many many thanks for pypy. Your work on pypy is exceptional.<br>
<br>
Due to Roger Binns doing the first steps of porting APSW on top of pypy,<br>
i've tried my project (madIS: <a href="http://code.google.com/p/madis" target="_blank">http://code.google.com/p/madis</a> ) with pypy<br>
and head APSW, and found the following:<br>
<br>
In python 2.7.1:<br>
In [1]: print dict.__setattr__<br>
<slot wrapper '__setattr__' of 'object' objects><br>
<br>
In pypy 1.5:<br>
In [10]: print dict.__setattr__<br>
<unbound method dict.__setattr__><br>
<br>
In essence in python 2.7.1 dict.__setattr__ is the same as<br>
object.__setattr__ whereas in pypy dict.__setattr__ works only with<br>
dictionaries, so it throws the following error when called with an object:<br>
<br>
TypeError: unbound method __setattr__() must be called with dict<br>
instance as first argument<br>
<br>
Above problem was solved by changing all dict.__setattr__ invocations<br>
into object.__setattr__ invocations, and now the same code works in both<br>
CPython and pypy.<br></blockquote><div><br>Actually, this feels a bit like it was a portability issue in your code to me. Why should dict's __setattr__ apply to all objects? Doesn't it seem more natural that it would apply to dicts alone, and if it applies to more, that that's an implementation detail?<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The second problem that i found with pypy is this:<br>
<br>
In [12]: import xml.etree.c<br>
xml.etree.cElementTree<br>
<br>
Above is to show that cElementTree exists in pypy's xml.etree. If then i<br>
try to import cElementTree:<br>
<br>
In [11]: import xml.etree.cElementTree<br>
---------------------------------------------------------------------------<br>
ImportError Traceback (most recent call last)<br>
<br>
/home/estama/programs/pypy-15/bin/<ipython console> in <module>()<br>
<br>
/home/estama/programs/pypy-15/lib-python/2.7/xml/etree/cElementTree.pyc<br>
in <module>()<br>
1 # Wrapper module for _elementtree<br>
<br>
2<br>
----> 3 from _elementtree import *<br>
<br>
ImportError: No module named _elementtree<br>
<br>
Thanks again for pypy, and to Roger Binns for your outstanding work on APSW.<br></blockquote><div><br>PyPy in general doesn't include a bunch of C extension modules; it's written in Python and RPython, so this seems somewhat natural. Your code probably should do something like:<br>
<br>try:<br> import xml.etree.cElementTree as element_tree<br>except ImportError:<br> import xml.etree.ElementTree as element_tree<br><br>...and then use element_tree.whatever in your code. It's 3 more lines, but more portable.<br>
<br>HTH.<br><br></div></div>