Re: Performance impact of using decorators

2006-03-11 Thread Peter Otten
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): >

Re: Performance impact of using decorators

2006-03-10 Thread Alex Martelli
vinjvinj <[EMAIL PROTECTED]> wrote: > >>what exactly made you think that Python would be able to run your > >>code *without* calling your function ? > > I was hoping that when the compiler finds decorators with wrapers that > have the same signature it can some how "magically" combine them into >

Re: Performance impact of using decorators

2006-03-10 Thread Alex Martelli
Diez B. Roggisch <[EMAIL PROTECTED]> wrote: ... > begin() > try: > pass > commit() > finally: > if not comitted(): > rollback() Feels like a natural for 2.5's 'with' statement -- as has been the case for 2.3 and 2.4, 2.5 won't have many language-level changes, but what little there IS

Re: Performance impact of using decorators

2006-03-10 Thread Diez B. Roggisch
vinjvinj schrieb: >>> That sounds like something for the templating engine, and _certainly_ not >>> for a decorator that otherwise deals with transactions. > > The actual code for the page layout is in a preppy template. But the > calls to the template engine are made in the > startTransactrionAnd

Re: Performance impact of using decorators

2006-03-10 Thread vinjvinj
>>what exactly made you think that Python would be able to run your >>code *without* calling your function ? I was hoping that when the compiler finds decorators with wrapers that have the same signature it can some how "magically" combine them into one function (which gets called at run time) and

Re: Performance impact of using decorators

2006-03-10 Thread Terry Reedy
"vinjvinj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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

Re: Performance impact of using decorators

2006-03-10 Thread Fredrik Lundh
"vinjvinj" wrote: > I was fearing that. The expose decorator is the only one that comes > with cherrypy. The other ones are mine and are of the format: > > def decorator(func): > def wrapper(self, *args, **kwargs) > some code > return wrapper what exactly made you think that Pyth

Re: Performance impact of using decorators

2006-03-10 Thread vinjvinj
>>That sounds like something for the templating engine, and _certainly_ not >>for a decorator that otherwise deals with transactions. The actual code for the page layout is in a preppy template. But the calls to the template engine are made in the startTransactrionAndBuildPage decorator >>Templat

Re: Performance impact of using decorators

2006-03-10 Thread Fredrik Lundh
"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): >

Re: Performance impact of using decorators

2006-03-10 Thread Diez B. Roggisch
> @expose -> cherrypy decorator > @startTransactrionAndBuildPage -> starts a db transaction, populates > the user in the session. I guess that is ok - transaction handling is a "classic" for decorator-like concepts. After all, you don't want begin() try: pass commit() finally: if not comitt

Re: Performance impact of using decorators

2006-03-10 Thread vinjvinj
>> solution. I'm not going to tell you that decorators aren't the answer to >>all programming problems, because you already know that in your heart :- I was fearing that. The expose decorator is the only one that comes with cherrypy. The other ones are mine and are of the format: def decorator(fu

Re: Performance impact of using decorators

2006-03-10 Thread Steve Holden
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): >s

Re: Performance impact of using decorators

2006-03-10 Thread Alex Martelli
vinjvinj <[EMAIL PROTECTED]> 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

Performance impact of using decorators

2006-03-10 Thread vinjvinj
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