[Pythonmac-SIG] Applet/compilation oddities?

Jack Jansen jack@oratrix.nl
Sat, 06 Oct 2001 00:59:56 +0200


Recently, Michael Dunn <mdunn@cantares.on.ca> said:
>     At 12:06 AM +0200 2001/10/5, Jack Jansen wrote:
> >Michael,
> >I'm not sure what you mean by "compiling with optimization on" in this
> >context. Could you give a recipe of what you're doing?
> 
>     Run EditPythonPrefs and select Optimize Bytecode.  IDE's Save as 
> Applet and running BuildApplet are unaffected, but using compile() 
> (from py_compile) results in the smaller .pyo file, yet still 
> containing docstrings and multiline comments.

Ah. A few things:
- "optimize bytecode" affects the underlying interpreter, not so much
the IDE. And apparently the IDE doesn't look at this setting when it
generates applets. Just: what do you think, is this your problem or my
problem? :-)

> Yet I'm sure I read 
> somewhere that this option's main function is to remove docstrings. 

No, on Unix there's an option -OO to do that, but there's no UI to set
that for MacPython yet. Please put in a feature request (assigned to
me) in the sourceforge tracker for this and I'll get to it eventually.

By the way, I assume that by "multiline comments" you mean things in
triple quotes? These are really strings (just like docstrings) and
hence end up in the code. For comments you should really use #.

>     yes.  I also just discovered that every Mac applet I create (eg 
> from the IDE) has a data fork of 772 bytes!  Seems all the "data" is 
> in the resource fork.  How strange.

That's right. The data fork only contains a tiny CFM code fragment
that calls out to PythonCore or PythonCoreCarbon. The resource for
contains your .pyc code (in a 'PYC ' resource) plus standard things
like icons, size and cfrg resources and other stuff.
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.cwi.nl/~jack        | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm