It seems like we can adopt properties and __slots__ piecemeal.
1) Add a foo = property(foo, setFoo, None, None) call for each property.
Monitor performance to verify it doesn't go down. If it doesn't, we're
no worse off than we were.
Users can (almost) interchange the old calling scheme with the
new. The "almost" is that there's a name collision between
the get method .foo() and the property .foo . You either have
to rename the get method or let it become inaccessible directly.
We can't eliminate the accessor methods entirely, because
they're needed to create the property from. Likewise, we
can't eliminate ._fields because we have to store the
dictionary *somewhere*. We could delete the accessor methods
after creating the property, or create the accessor functions
in the constructor (messy?).
Tavis, can you post the .field algorithm you were considering?
2) Sometime later, migrate the docstrings into the properties.
3) Sometime later, add __slots__ . Wait a while for __slots__ to
mature and possibly change. If people write 'self.foa = 1234'
instead of 'self.foo = 1234' in the meantime, they'll be no worse off
than they are under normal Python practice.
The docs are ambiguous about whether __slots__ gives a speed
performance. If it's implemented the way local variables are,
it would be a big speed improvement, because it could do list
subscripting rather than dictionary lookup. On the other hand,
if every access implicitly does
index = self.__slots__.index(foo)
performance may be worse than with a __dict__.
If people will be changing their servlets to eliminate (), it's
better to do it now rather than later when more sites are deployed,
and especially before 1.0. Otherwise, we'll be stuck with
.foo() and .setFoo() forever.
On the other hand, switching over to properties will require
significant developer work, so it 'tain't gonna happen unless
somebody is sufficiently motivated to do it.
For an easier and smaller change if we don't use properties, note that
Perl programmers use one method for getting and setting.
.foo(newvalue=NotGiven) would eliminate the need for .setFoo and thus
cut down on the multiplicity of accessor methods.
--
-Mike (Iron) Orr, [EMAIL PROTECTED] (if mail problems: [EMAIL PROTECTED])
http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss