Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Mon Jul 11 19:32:49 EDT 2005
--- Rob Williscroft <rtw at freenet.co.uk> wrote:
> class MyClass(object):
> @init_self
> def __init__( self, x, _y, z ):
> print "in __init__() _y =", _y
Here are the timings (script attached):
overhead: 0.01
plain_grouping: 0.26
update_grouping: 0.45
plain_adopt_grouping: 0.69
autoinit_grouping: 1.14
autoinit_setattr_grouping: 1.07
autoattr_grouping: 1.01
decorated_init_grouping: 0.94
I think your decorator solution looks nice and has a good potential time-wise.
Cheers,
Ralf
____________________________________________________
Sell on Yahoo! Auctions no fees. Bid on great items.
http://auctions.yahoo.com/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: autoinit_timings.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20050711/856afdc6/attachment.ksh>
More information about the Python-list
mailing list