Compiler directives in the source

Michael Hudson mwh at python.net
Thu Feb 6 07:52:50 EST 2003


Dale Strickland-Clark <dale at riverhall.NOTHANKS.co.uk> writes:

> I think the following compiler options would be usefully avilable as
> directives in the source as well as on the command line:
> 
> -O     : optimize generated bytecode 
> -OO    : remove doc-strings in addition to the -O optimizations

Would be a pain in the ass to implement.  Could be done, but given how
much difference -O makes in 2.3...

> -Q arg : division options:

Got that one:

from __future__ import division

> -S     : don't imply 'import site' on initialization

Huh?  You'd specify this in the main Python program or something?  It
can't make a difference in a module.

-QUITEALOT.

> -v     : verbose (trace import statements) (also PYTHONVERBOSE=x)

Noo!!  Run away!

> -W arg : warning control 

Got this already.

> -x     : skip first line of source

I've never understood the purpose of -x.

> To that list, I would like to add:
> 
> debug arg : control value of __debug__ and assert() (independent of
>             optimisation)

But that's all -O affects in 2.3!

[...]
> Advantages: Flexible and easily extended. Easier to remember. Simple
> syntax. Comments stay as comments. 

I think "easily extended" is actually a disadvantage.

> Disadvantages: Too late? Bigger code change?

It might have been better if the coding cookie was

%encoding: utf8

or something, but then you'd probably have to duplicate it: once for
Python, once for Emacs... I guess emacs could probably have been
taught about Python's convention rather than vice-versa.

Oh, well, I'm personally happy enough with the status quo, so I'm just
going to stop :-)

Cheers,
M.

-- 
  The only problem with Microsoft is they just have no taste.
              -- Steve Jobs, (From _Triumph of the Nerds_ PBS special)
                         and quoted by Aahz Maruch on comp.lang.python




More information about the Python-list mailing list