<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
Phil Thompson schrieb:<br>
<blockquote type="cite"
cite="mid200402181923.40316.phil@riverbankcomputing.co.uk">
<pre wrap="">On Wednesday 18 February 2004 19:04, Eron Lloyd wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Would there be any benefit in doing this? From the way I understand it, all
Qt objects already expose their get/set methods, while any objects you
create through subclassing can simply use Python's native properties
support. For the most part, properties have their biggest value in use with
Designer.
Eron
</pre>
</blockquote>
<pre wrap=""><!---->
I agree, it just duplicates existing functionality at the cost of code bloat.
</pre>
</blockquote>
<tt>Not only code bloat, also a performance penalty.<br>
<br>
Look at the following test class and the two methods to get and set an
attribute:<br>
</tt><br>
<tt>--------------------------------------------------</tt><br>
<tt>class PropertyTest(object):</tt><br>
<tt> def getValue(self):</tt><br>
<tt> return self._value</tt><br>
<tt> def setValue(self, value):</tt><br>
<tt> self._value = value</tt><br>
<tt> value = property(getValue, setValue, None)</tt><br>
<tt>--------------------------------------------------</tt><br>
<tt>x = PropertyTest()</tt><br>
<tt>for i in xrange(100000):</tt><br>
<tt> x.setValue("TEST")</tt><br>
<tt> a = x.getValue()</tt><br>
<tt> x.setValue(a.swapcase())</tt><br>
<tt>--------------------------------------------------</tt><br>
<tt>x = PropertyTest()</tt><br>
<tt>for i in xrange(100000):</tt><br>
<tt> x.value = "TEST"</tt><br>
<tt> a = x.value</tt><br>
<tt> x.value = a.swapcase()</tt><br>
<tt>--------------------------------------------------</tt><br>
<tt><br>
</tt><tt>On my Linux box with Python-2.3.3, the second method has only <b>~75%</b>
of the performance of the first method.<br>
<br>
Nevertheless it makes sense to implement QMetaObject and QMetaProperty,
just in case someone plans to build a kind of dialog editor with PyQt
(in the future, we want to give our customers the facility to create or
modify dialogs or dialog components inside the application).<br>
<br>
Ulli<br>
</tt><br>
</body>
</html>