Decorators, Identity functions and execution...

Chance Ginger cginboston at hotmail.com
Sun Apr 9 02:57:55 EDT 2006


If I define a decorator like:

def t(x) :
	def I(x) : return x
	return I

and use it like:

@t(X)
def foo(a) :
	# definition of foo...
	pass

or maybe this:

@t(X)
@(Y)
def bar(a) :
	# The definition of bar...


Will in encounter much of a penalty in executing 
'foo' or 'bar'? If so, is there a way to define
t such that Python knows it is the identity function
and short-circuit evaluation?

Thanks in advance.



More information about the Python-list mailing list