bytecode -> code object
Steven D. Majewski
sdm7g at virginia.edu
Thu Sep 14 12:09:11 EDT 2000
On Thu, 14 Sep 2000, dr. franken wrote:
>
> I feed Py_CompileString with python source, and I get a code object - fine.
> But how do I get a code object from (a string containing) python bytecode?
>
Look at the 'new' module. If you want to do it from C, then take
a look at newmodule.c to see how it's done.
>>> import new
>>> print new.__doc__
Functions to create new objects used by the interpreter.
You need to know a great deal about the interpreter to use this!
>>> dir(new)
['__doc__', '__file__', '__name__', 'classobj', 'code', 'function',
'instance',
'instancemethod', 'module']
>>> print new.code.__doc__
Create a code object from (ARGCOUNT, NLOCALS, STACKSIZE, FLAGS,
CODESTRING, CONSTANTS, NAMES, VARNAMES, FILENAME, NAME, FIRSTLINENO, LNOTAB).
>>>
---| Steven D. Majewski (804-982-0831) <sdm7g at Virginia.EDU> |---
---| Department of Molecular Physiology and Biological Physics |---
---| University of Virginia Health Sciences Center |---
---| P.O. Box 10011 Charlottesville, VA 22906-0011 |---
"All operating systems want to be unix,
All programming languages want to be lisp."
More information about the Python-list
mailing list