[Zope3-dev] PythonProgrammerTutorial

Jim Fulton jim@zope.com
Thu, 06 Dec 2001 07:34:44 -0500


Martijn Faassen wrote:
> 
> 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.

Yup or evan explicit acquisition.

> Another
> approach would be to pass the context object explicitly to the feature
> singleton's methods.

I really don't like that.

> Both these would avoid object creation, which is
> slow in Python.

I wonder about that. 

> 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

It's not clear how to interpret this. It looks to me like
object creation is fast in both Python and Java, but Java is faster.
The numbers for object creation are the lowest and repetition is the
highest, 10 million.
 
> but I expect improving this isn't considered to be easy as otherwise
> it'd have been done already.

Or maybe nobody complained?

I'm sure there's more that can be done of there is a problem.

Jim

--
Jim Fulton           mailto:jim@zope.com       Python Powered!        
CTO                  (888) 344-4332            http://www.python.org  
Zope Corporation     http://www.zope.com       http://www.zope.org