Just when you thought bytecodehacks couldn't provide anything more unlikely - your chance to bypass that pesky compiler and write directly to the virtual machine. Currently very limited; no jumps(!), default arguments, * or ** args or classes. But it's a proof of concept.
Assembly input looks like this:
IMPORT_NAME sys
LOAD_ATTR path
PRINT_ITEM
PRINT_NEWLINE
LOAD_CONST !1
STORE_NAME frig
function foo x
LOAD_FAST x
LOAD_CONST !1
BINARY_ADD
STORE_FAST y
LOAD_FAST y
LOAD_FAST y
BINARY_ADD
RETURN_VALUE
end
function n
LOAD_GLOBAL frig
DUP_TOP
BINARY_ADD
RETURN_VALUE
end
LOAD_CONST !None
RETURN_VALUE
and then the following code can be used to make a module from the above (assuming the above is in a file called ``assdemo.pya''):
from bytecodehacks import assemble
mod = assemble.assemble("assdemo.pya")
There's not going to be any more detailed documentation for a while, because its all probably going to change at least once. I need to work out a syntax for jumps, for starters.
Send comments to mwh@python.net