@decorator syntax is sugar, but for what exactly? (decorator libraries).

ajsiegel at optonline.net ajsiegel at optonline.net
Wed Aug 11 11:25:59 EDT 2004


>    >> Yes (using a class instead of a module simply for convenience):
>    ...
> 
>    Art> Is it me, or this a chilling argument agaisnt where 
> things are
>    Art> going.
> 
> I'm not sure what you're getting at.  Nobody said a decorator's
> implementation had to be simple.  It can, after all, perform pretty
> arbitrary transformations.

I guess, as a reading experience, I find enough dissonance to lose motivation
to make the effort to follow the flow.

Purely subjective. I offer this as a barometric reading from the point of view of
a certain segment of the Python reading public.  

Understanding that part of what I am up against is unavoidable complexity in
he code, and following would not be child's play to me, in any case.
Something though puts it beyond my cognative -what, interest.

> 
>    Art> But when there is a lot less going on than meets the eye ...
> 
> Again, I'm confused.  Look at just the fib() definition:
> 
>    @martha.memoize
>    def fib(n):
>        assert n >= 0
>        print n
>        if n <= 1:
>            return 1
>        return n + fib(n-1)
> 
> The decorator says the function will be memoized.  That memoizing an
> arbitrary function's values using a dict isn't entirely 
> straightforwardshouldn't prevent people from being able to easily 
> memoize functions whose
> outputs only depend on their inputs.  By analogy, I use 
> urllib.urlopen() all
> the time without completely understanding all the ins and outs of 
> what it
> does.
> 
> Perhaps the decorator would be better named "idempotent"?
> 
> Or were you objecting to something else?

Well, I one hand I understand decorators to be syntatical sugar for existing
Python functionality, and on the other I hear talk of the building of decorator
libraries based on the introduction of decorators, as if we were talking about a
new classs of functionality.

Certainly the introduction of decorators seems to be encouraging a new style of
programming.  That style might be have advantages.  And it might in fact be
good for someone exactly like myself, to be exposed to more of it.  

But it does seem to me readibility will be a casualty.

And I fear decorator libraries working to make Python ingrown.

Art




More information about the Python-list mailing list