Re: Using bytecode, not code objects

2006-02-10 Thread Christos Georgiou
On Sun, 29 Jan 2006 14:51:18 -0800, rumours say that Michael Spencer
[EMAIL PROTECTED] might have written:

 http://www.effbot.org/librarybook/marshal.htm
 
There's a typo in the text accompanying that example: img.get_magic() should 
be 
imp.get_magic().

The error is easy to explain: he's on PIL(s) for years.
-- 
TZOTZIOY, I speak England very best.
Dear Paul,
please stop spamming us.
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using bytecode, not code objects

2006-02-06 Thread Fabiano Sidler
2006/1/29, Fabiano Sidler [EMAIL PROTECTED]:
 28 Jan 2006 22:02:45 -0800, Raymond Hettinger [EMAIL PROTECTED]:
  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.

 Thanks! I think this will help me, because it demonstrates how a code
 object is to be created (with new.code), although in a very
 complicated way.

Are you familiar with this module? I don't get the essence of it, even
with pdb (which I'm surely not using as neatly as it could be). Or is
there any documentation on it I couldn't find?

Greetings,
F. Sidler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using bytecode, not code objects

2006-02-06 Thread Raymond Hettinger

Fabiano Sidler wrote:
 2006/1/29, Fabiano Sidler [EMAIL PROTECTED]:
  28 Jan 2006 22:02:45 -0800, Raymond Hettinger [EMAIL PROTECTED]:
   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.
 
  Thanks! I think this will help me, because it demonstrates how a code
  object is to be created (with new.code), although in a very
  complicated way.

 Are you familiar with this module? I don't get the essence of it, even
 with pdb (which I'm surely not using as neatly as it could be). Or is
 there any documentation on it I couldn't find?

The pysassem module is part of the compiler package:

   http://docs.python.org/lib/compiler.html


Raymond

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using bytecode, not code objects

2006-02-06 Thread Terry Reedy

Raymond Hettinger [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Fabiano Sidler wrote:
 with pdb (which I'm surely not using as neatly as it could be). Or is
 there any documentation on it I couldn't find?

 The pysassem module is part of the compiler package:

   http://docs.python.org/lib/compiler.html

The 2.4 docs, which the above links to, only has sections on modules 
compiler, compiler.ast, and compiler.visitor and not on .consts, .future, 
.misc, .pyassem, .pycodegen, .symbols, and .transformer.  However,

import compiler
help(compiler.ast)

gives a few pages of info derived from the module.

Terry Jan Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using bytecode, not code objects

2006-01-29 Thread Fredrik Lundh
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



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using bytecode, not code objects

2006-01-29 Thread Michael Spencer
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


Re: Using bytecode, not code objects

2006-01-28 Thread Raymond Hettinger
[Fabiano Sidler]
 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
hand.


Raymond

-- 
http://mail.python.org/mailman/listinfo/python-list