Using bytecode, not code objects
python at rcn.com
Sun Jan 29 01:02:45 EST 2006
> 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.
> 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.
Why not? The code object gives you all of these values directly.
But if you want to make your life unnecessarily hard, you can hack the
compiler module just upstream from the creation of the code object --
alter the newCodeObject() method in pyassem.py.
It's a pointless exercise, but maybe you'll have fun doing it or
perhaps learn not to avoid obvious, direct solutions to the problem at
More information about the Python-list