Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Sat Jul 9 04:08:05 EDT 2005
--- NickC <ncoghlan at gmail.com> wrote:
> I'd be very interested to hear your opinion on the 'namespace' module,
> which looks at addressing some of these issues (the Record object, in
> particular). The URL is http://namespace.python-hosting.com, and any
> comments should be directed to the namespace at googlegroups.com
> discussion list.
Hi Nick,
The namespace module looks interesting, thanks for the pointer! (I saw your
other message but didn't have a chance to reply immediately.)
I tried out the namespace.Record class. The resulting user code looks nice, but
I have two concerns:
- It requires a different coding style; until it is well established it will
surprise people.
- The runtime penalty is severe.
Attached is a simple adopt_timings.py script. If I run it with Python 2.4.1
under RH WS3, 2.8GHz Xeon, I get:
overhead: 0.01
plain_grouping: 0.27
update_grouping: 0.44
plain_adopt_grouping: 0.68
record_grouping: 10.85
I.e. record_grouping (using namespace.Record) is about 40 times slower than the
manual self.x=x etc. implementation.
My conclusion is that namespace.Record may have merits for specific purposes,
but is impractical as a general-purpose utility like I have in mind.
Note that the attached code includes a new, highly simplified "plain_adopt()"
function, based on the information I got through other messages in this thread.
Thanks to everybody for suggestions!
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: adopt_timings.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20050709/784a650c/attachment.ksh>
More information about the Python-list
mailing list