PyVM: Python Bytecode interpreter, in Python
An idea I've been toying around with is a Python bytecode interpreter, written in Python. Currently, it works decently, supporting pretty much everything except generators. Might be useful to look at. The code is available at: http://www.twistedmatrix.com/users/z3p/files/pyvm2.py -p -- Paul Swartz (o_ http://twistedmatrix.com/users/z3p.twistd/ //\ z3p@twistedmatrix.com V_/_ AIM: Z3Penguin
Paul Swartz wrote:
An idea I've been toying around with is a Python bytecode interpreter, written in Python. Currently, it works decently, supporting pretty much everything except generators. Might be useful to look at. The code is available at: http://www.twistedmatrix.com/users/z3p/files/pyvm2.py
Ho hoo! That's pretty nice to read, something like the very basic bytecode interpreter, based upon representations of the internal obejcts, emulated using Python's basic builtin types. This looks pretty much like something that Holger suggested, partially. It is not implementing the new class/type system, so I guess it is based upon Python 2.0? Yes, I see byte_CALL_FUNCTION, which has been split into some more for 2.2 and up. I see the individual byte codes being implemented as small functions. That is very much as I like it. You are not trying to implement the basic stuff, but you borrow it from the Python interpreter, like print. You are also borrowing lists, tuples and dicts, the interpreter is just a mapping of bytecodes to builtin actions. That's fine to start with! I saw a generator class, at least. This is just not working, right? I had only five minutes yet to read it. Nice thing, thanks for showing it to us! This is exactly the kind of input we need. sincerely -- chris -- Christian Tismer :^) <mailto:tismer@tismer.com> Mission Impossible 5oftware : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 89 09 53 34 home +49 30 802 86 56 pager +49 173 24 18 776 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/
On 13 Jan 2003 at 2:11, Christian Tismer wrote:
You are not trying to implement the basic stuff, but you borrow it from the Python interpreter, like print. You are also borrowing lists, tuples and dicts, the interpreter is just a mapping of bytecodes to builtin actions. That's fine to start with!
Yes, ATM I borrow lists, tuples, and dicts, but once I work out new-style classes, I think I'll wrap them and everything in a generic PyObject class, to make them behave like Objects do now.
I saw a generator class, at least. This is just not working, right? I had only five minutes yet to read it.
Yes, there's a Generator class, but I've had some trouble getting them implemented, so the test for them and the code that would create them is disabled. -p -- Paul Swartz (o_ http://twistedmatrix.com/users/z3p.twistd/ //\ z3p@twistedmatrix.com V_/_ AIM: Z3Penguin
Paul Swartz wrote:
On 13 Jan 2003 at 2:11, Christian Tismer wrote:
...
I saw a generator class, at least. This is just not working, right? I had only five minutes yet to read it.
Yes, there's a Generator class, but I've had some trouble getting them implemented, so the test for them and the code that would create them is disabled.
Can I count on you participating in our sprint! -- Christian Tismer :^) <mailto:tismer@tismer.com> Mission Impossible 5oftware : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 89 09 53 34 home +49 30 802 86 56 pager +49 173 24 18 776 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/
participants (2)
-
Christian Tismer -
Paul Swartz