Using bytecode, not code objects

Fredrik Lundh fredrik at pythonware.com
Sun Jan 29 03:51:25 EST 2006


Fabiano Sidler wrote:

> I'm looking for a way to compile python source to bytecode instead of
> code-objects. Is there a possibility to do that? The reason is: I want
> to store pure bytecode with no additional data.

use marshal.

> The second question is, therefore: How can I get the correct values
> for a given bytecode, such as the stacksize and flags attributes of
> the correspondent code object?
>
> No, I don't want to extract all of these things out of a code object.

you don't have to.  marshal can convert a code object to a single byte
string, which contains everything you need.  see the second example on
this page for sample code:

    http://www.effbot.org/librarybook/marshal.htm

</F>






More information about the Python-list mailing list