"vinjvinj" wrote:

> I'm building an application with cherrypy and have started using
> decorators quite extensively. A lot of my exposed functions look like:
>
> @expose
> @startTransactrionAndBuildPage
> @partOfTabUi(tabId)
> @convert(arg1=int, arg2=str)
> def do_main_page(self, arg1, arg2):
>    some code
>
> I've become really fond of decorators and use them quite a lot. I've
> also ready that function calls are expensive in python. In the above
> example, does the interpreter call 5 different functions?

the decorators themselves are only called when the function is defined.

what happens at runtime depends on what the decorators do (in pretty
much the same way as the output and execution time for this script

    x = lambda: return "hello"
    x = foo(x)
    x = fie(x)
    x = fum(x)
    print x()

depends on what the foo, fie, and fum functions do...)

</F>



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

Reply via email to