[Python-Dev] A syntax for function attributes?
Pat Miller
patmiller@llnl.gov
Wed, 30 Jul 2003 11:45:16 -0700
I can imagine lots of ways that these attributes can be useful
and would like to see this extension in some form. If nothing
else, they can be used to help guide optimizations.
I can imagine:
def sqr [inline=true](x):
return x*x
or
def debug [debug_only=true](*messages):
global debugging
if debugging:
print "DEBUG",' '.join([str(x) for x in messages])
return
In the first case, maybe a bytecode inliner could move the code into a caller
In the second case, if debugging were turned off, the function call
could be made into a NOP.
I think it essential to use some dense syntax. It would be messy if it
were
def sqr(x):
return x*x
sqr.inline = true
Pat
--
Patrick Miller | (925) 423-0309 | http://www.llnl.gov/CASC/people/pmiller
Fanaticism consists of redoubling your efforts when you have forgotten your
aim. -- George Santayana