[RFC/MERGE] Updates to decorators
Andrew Bennetts
andrew at canonical.com
Fri Jan 12 11:30:22 GMT 2007
John Arbash Meinel wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I have 2 updates to our current decorators, one follows on the other
> one, but is a little more controversial.
>
> Basically, I've been doing lsprof testing, and I've been getting
> frustrated with the 'read_locked()' functions. Because in a big test,
> you can have 10 or more @needs_read_lock functions. So when you are
> tracking up from the bottom, or down from the top, you frequently hit a
> barrier which makes it difficult to tell who is calling what. (10
> functions call "read_locked()" and read_locked calls 10 other functions,
> so which is being called without going to the source?)
>
> The first pass changes the needs_read_lock and needs_write_lock
> decorators so that they use 'exec' to create a function with the a
> mostly correct name (plus a _read_locked suffix). In testing, it was
> enough to make sure that functions could be uniquely determined. In
> theory if we have Branch.get() and Repository.get() they would end up
> having the same function signatures.
Why isn't the existing setting of __name__ adequate to do this? Maybe __module__
needs to be set as well?
[...]
> The second patch extends the first one by making the wrapping created
> function also include the same parameters as the original function. It
> uses 'inspect' to do most of the introspection. What this really changes
> is the results when doing help(function). Specifically the difference is:
>
[...]
> fetch(self, *args, **kwargs) unbound bzrlib.branch.Branch method
[...]
> fetch(self, from_branch, last_revision=None, pb=None) unbound
This is a limitation of the pydoc and epydoc tools, but PyDoctor at least
generates the right output with the existing decorator.
-Andrew.
More information about the bazaar
mailing list