[Zope3-dev] PythonProgrammerTutorial

Martijn Faassen faassen@vet.uu.nl
Thu, 6 Dec 2001 12:55:26 +0100


Jim Fulton wrote:
> > So feature lookups in the feature service can also be placeful? Or perhaps
> > alternatively, the feature service to use in a place can be dependent on the
> > place?
> 
> Yes.  When you:
> 
>   getFeature(ob, I)
> 
> the component architecture find the closest Feature
> service to ob and then call getFeature on it to find
> a feature registered for the interfaces implemented by
> ob.  It can delegate to other feature services later.

All right, it wasn't clear to me yet that services could be placeful; 
while I find a description of utilities indicating they were, services
didn't give me that impression yet.

Excellent. That makes very interesting applications possible. Now my
main worry devolves to 'would all this feature wrapping be fast enough'.
My experiences with ParsedXML and XMLWidgets are that it can be slow, though
in many cases we're dealing with rendering of largish trees and not one
or a few objects. Still, one would expect this to happen in other circumstances
as well, and all the work creating objects can lead to user-noticable pauses..

To alleviate this problem, if it occurs, we could try a kind of magic 
singleton wrapping implementation using implicit acquisition, so that a
single feature object can act for many different other objects. Another
approach would be to pass the context object explicitly to the feature
singleton's methods. Both these would avoid object creation, which is
slow in Python.

Alternatively we could advocate faster object creation in Python. See the
'object allocation' entry in this Python versus Java comparison for
some data on that:

http://www.twistedmatrix.com/users/glyph/rant/python-vs-java.html

but I expect improving this isn't considered to be easy as otherwise
it'd have been done already.

Regards,

Martijn