Fredrik Lundh wrote: > 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> > > > There's a typo in the text accompanying that example: img.get_magic() should be imp.get_magic().
Michael -- http://mail.python.org/mailman/listinfo/python-list