tag:blogger.com,1999:blog-3971202189709462152.post3785910476193156295..comments2024-03-11T12:50:02.036+01:00Comments on PyPy Status Blog: Tutorial: Writing an Interpreter with PyPy, Part 1Carl Friedrich Bolz-Tereickhttp://www.blogger.com/profile/00518922641059511014noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-3971202189709462152.post-38361564207760048822015-12-02T06:50:17.996+01:002015-12-02T06:50:17.996+01:00I followed this tutorial again several years later...I followed this tutorial again several years later :) (just for fun) using the newly published rpython toolchain now available up on PyPi. You can now just: pip install rpython -- I also wanted to point out that recent versions of the RPython toolchain have made advances in what it can translate it seems; specifically I did not need to change the open(...).read() parts to lower level os.read() calls.Jameshttps://www.blogger.com/profile/07048331604887530257noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-65689735808451898572013-08-26T13:25:43.471+02:002013-08-26T13:25:43.471+02:00I think that your "," implementation is ...I think that your "," implementation is incorrect, os.read returns an empty string on EOF, thus [0] triggers an exception.<br />According to Wikipedia, setting the cell to 0, -1 or leaving the cell unchanged each may be used to tell EOF apart from other characters.Dvd Fonoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-65090405787631513062013-02-23T03:12:30.917+01:002013-02-23T03:12:30.917+01:00Now, with os.read() and os.write():
[translation:...Now, with os.read() and os.write():<br /><br />[translation:ERROR] Error:<br />[translation:ERROR] Traceback (most recent call last):<br />[translation:ERROR] File "/opt/local/lib/pypy/src/pypy-pypy-07e08e9c885c/pypy/translator/goal/translate.py", line 303, in main<br />[translation:ERROR] drv.proceed(goals)<br />[translation:ERROR] File "/opt/local/lib/pypy-2.0-b1/src/pypy-pypy-07e08e9c885c/pypy/translator/driver.py", line 771, in proceed<br />[translation:ERROR] return self._execute(goals, task_skip = self._maybe_skip())<br />[translation:ERROR] File "/opt/local/lib/pypy-2.0-b1/src/pypy-pypy-07e08e9c885c/pypy/translator/tool/taskengine.py", line 116, in _execute<br />[translation:ERROR] res = self._do(goal, taskcallable, *args, **kwds)<br />[translation:ERROR] File "/opt/local/lib/pypy-2.0-b1/src/pypy-pypy-07e08e9c885c/pypy/translator/driver.py", line 283, in _do<br />[translation:ERROR] res = func()<br />[translation:ERROR] File "/opt/local/lib/pypy-2.0-b1/src/pypy-pypy-07e08e9c885c/pypy/translator/driver.py", line 319, in task_annotate<br />[translation:ERROR] s = annotator.build_types(self.entry_point, self.inputtypes)<br />[translation:ERROR] File "/opt/local/lib/pypy-2.0-b1/src/pypy-pypy-07e08e9c885c/pypy/annotation/annrpython.py", line 89, in build_types<br />[translation:ERROR] return self.build_graph_types(flowgraph, inputcells, complete_now=complete_now)<br />[translation:ERROR] File "/opt/local/lib/pypy-2.0-b1/src/pypy-pypy-07e08e9c885c/pypy/annotation/annrpython.py", line 142, in build_graph_types<br />[translation:ERROR] self.complete()<br />[translation:ERROR] File "/opt/local/lib/pypy-2.0-b1/src/pypy-pypy-07e08e9c885c/pypy/annotation/annrpython.py", line 217, in complete<br />[translation:ERROR] raise AnnotatorError(text)<br />[translation:ERROR] AnnotatorError: -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+<br />[translation:ERROR] Blocked block -- operation cannot succeed<br />[translation:ERROR]<br />[translation:ERROR] v1 = ord(v0)<br />[translation:ERROR] In :<br />[translation:ERROR] Happened at file /Users/cacilhas/Workspace/Personal/brainfuck/src/brainfuck/parser.py line 29<br />[translation:ERROR]<br />[translation:ERROR] ==> tape.set(ord(os.read(0, 1)))<br />[translation:ERROR]<br />[translation:ERROR] Known variable annotations:<br />[translation:ERROR] v0 = SomeString(can_be_None=True)ℭacilhας, ℒa ℬatalemahttps://www.blogger.com/profile/14265747724618147106noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-32068281841671500282013-02-14T06:44:13.978+01:002013-02-14T06:44:13.978+01:00This is a great post for anyone interested in prog...This is a great post for anyone interested in programming languages :) Great post!James Millshttp://prologic.shortcircuit.net.au/noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-46227553201670810942011-12-12T02:15:49.482+01:002011-12-12T02:15:49.482+01:00Nice post. I just want to report that I tried runn...Nice post. I just want to report that I tried running<br /><br /> /usr/share/pypy-1.6/pypy/translator/goal/translate.py example2.py<br /><br />and got the following error.<br />This is with an Ubuntu 1.7 pypy package rebuilt on Debian squeeze (the 1.6 is a typo, it should be 1.7).<br /><br />[translation:ERROR] Error:<br />[translation:ERROR] Traceback (most recent call last):<br />[translation:ERROR] File "/usr/share/pypy-1.6/pypy/translator/goal/translate.py", line 308, in main<br />[translation:ERROR] drv.proceed(goals)<br />[translation:ERROR] File "/usr/share/pypy-1.6/pypy/translator/driver.py", line 809, in proceed<br />[translation:ERROR] return self._execute(goals, task_skip = self._maybe_skip())<br />[translation:ERROR] File "/usr/share/pypy-1.6/pypy/translator/tool/taskengine.py", line 116, in _execute<br />[translation:ERROR] res = self._do(goal, taskcallable, *args, **kwds)<br />[translation:ERROR] File "/usr/share/pypy-1.6/pypy/translator/driver.py", line 286, in _do<br />[translation:ERROR] res = func()<br />[translation:ERROR] File "/usr/share/pypy-1.6/pypy/translator/driver.py", line 441, in task_backendopt_lltype<br />[translation:ERROR] from pypy.translator.backendopt.all import backend_optimizations<br />[translation:ERROR] File "/usr/share/pypy-1.6/pypy/translator/backendopt/all.py", line 2, in <br />[translation:ERROR] from pypy.translator.backendopt import removenoops<br />[translation:ERROR] File "/usr/share/pypy-1.6/pypy/translator/backendopt/removenoops.py", line 5, in <br />[translation:ERROR] from pypy import conftest<br />[translation:ERROR] File "/usr/share/pypy-1.6/pypy/conftest.py", line 1, in <br />[translation:ERROR] import py, pytest, sys, os, textwrap, types<br />[translation:ERROR] ImportError: No module named pytest<br />[translation] start debugger...<br />> /usr/share/pypy-1.6/pypy/conftest.py(1)()<br />-> import py, pytest, sys, os, textwrap, types<br />(Pdb+)<br /><br />So, it looks like pytest needs to be installed. This does not appear to be available as a Debian package.<br /><br />Regards, Faheem Mitha <br />(faheem at faheem dot info)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-22597055246171107332011-04-15T08:53:39.536+02:002011-04-15T08:53:39.536+02:00@Davide: you should compare your C version against...@Davide: you should compare your C version against the PyPy version WITH the JIT, as explained here:<br /><br />http://morepypy.blogspot.com/2011/04/tutorial-part-2-adding-jit.html<br /><br />I bet that PyPy will easily win :-)Antonio Cunihttps://www.blogger.com/profile/17017456817083804792noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-44727337919640198472011-04-15T04:52:50.452+02:002011-04-15T04:52:50.452+02:00Amazing! Thanks for posting. I was wondering, what...Amazing! Thanks for posting. I was wondering, what's about a pure C or C++ implementations, as close as reasonable to the python one? So I wrote them. You can read more details <a href="http://blog.javacorner.net/2011/04/pypy-wonders.html" rel="nofollow">here</a>, but the bottom line is that PyPy is (marginally) faster than C++, and (marginally) slower than C :-ODavidehttps://www.blogger.com/profile/11704832225616294007noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-11950927764092151792011-04-15T04:50:38.393+02:002011-04-15T04:50:38.393+02:00This comment has been removed by the author.Davidehttps://www.blogger.com/profile/11704832225616294007noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-38636769096833121502011-04-12T19:24:06.174+02:002011-04-12T19:24:06.174+02:00I like how this article became family-friendly by ...I like how this article became family-friendly by actually avoiding calling BF by its name :-)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-19716679083164378742011-04-08T11:32:42.890+02:002011-04-08T11:32:42.890+02:00Thanks. I've finally understood what PyPy is.Thanks. I've finally understood what PyPy is.anatoly techtonikhttps://www.blogger.com/profile/07847778636782899903noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-42391350283863007752011-04-06T15:52:16.966+02:002011-04-06T15:52:16.966+02:00@temptemptemp13: I think you are missing something...@temptemptemp13: I think you are missing something much more substantial. This article is not about Python at all. It is about how to use the PyPy toolchain to implement a different language - in this case the brainfuck programming language.<br /><br />While BF isn't a very useful language, it has the nice properties of being very small. Almost all of the language fits in a blog post.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-10136388570213865972011-04-06T11:22:54.490+02:002011-04-06T11:22:54.490+02:00Nice article though I'm really missing a simpl...Nice article though I'm really missing a simple benchmark between the python interpreter and the pypy interpreter. "Takes forever" vs "45 seconds" isn't as awesome of a conclusion as I'd hoped for.temptemptemp13https://www.blogger.com/profile/06584262299709169101noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-68467975768514288692011-04-06T05:09:44.136+02:002011-04-06T05:09:44.136+02:00On my Ubuntu 10.10 laptop, the PyPy BF interpreter...On my Ubuntu 10.10 laptop, the PyPy BF interpreter ran hanoi in ~20 sec and mandel in ~40 sec. By comparison, the beef BF interpreter (written in C) ran these in ~10 and ~20 sec., respectively. Not too shabby, PyPy.Paul Smithhttps://www.blogger.com/profile/11293578259382016176noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-3867340106055185702011-04-05T17:56:14.056+02:002011-04-05T17:56:14.056+02:00"devance"? I think you meant "retra..."devance"? I think you meant "retract".Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-71104433375703639672011-04-05T17:35:08.657+02:002011-04-05T17:35:08.657+02:00Hmmmmmm, yum.
I'm going to translate this int...Hmmmmmm, yum.<br /><br />I'm going to translate this into Chinese, if you don't mind?DaNmarnerhttps://www.blogger.com/profile/04967441038137239969noreply@blogger.comtag:blogger.com,1999:blog-3971202189709462152.post-16559995811310298092011-04-05T15:10:49.713+02:002011-04-05T15:10:49.713+02:00nice post!nice post!Dunkhttps://www.blogger.com/profile/06997740100179932354noreply@blogger.com