[XML-SIG] Ugh! Why are DOM access methods spelled with a leading '_'?

Jim Fulton jim@digicool.com
Mon, 26 Jun 2000 13:54:13 -0400


Mike Olson wrote:
> 
> Jim Fulton wrote:
> >
> > >
> > > Actually, the DOM can be mapped into a language in a manner that does
> > > not follow directly from the IDL and CORBA specs. That's why there is a
> > > formally defined java binding rather than just a reference to the IDL
> > > specs. Historically, though, 4DOM was really a CORBA tool so it really
> > > needed to follow the specs.
> >
> > Whatever we do, there needs to be a document somewhere that
> > says what the Python DOM mapping is, even if it is not
> > much more than a reference to the DOM IDL and the Python
> > binding.
> 
> In 4DOM, we are actually moving away from __getattr__ (for speed).

IMO, this is strong evidence that the Python DOM should
*not* use attributes for implementing the DOM/IDL attributes.

> We've found that we can keep all of the data cached in attributes for
> when it is needed.  The draw back is that 4DOM will break horribly if
> people access out side of the DOM interface (or 4DOM supported pythonic
> interface) and there is a bit of runtime performance lose, however that
> is minor compared to the perfomace hit from __getattr__.  The only
> reason we still support the '_'* is for legacy.

I'd like it to be as easy as possible for various objects to implement 
the DOM. (See for example StructuredTextNG.) I'd hate to make implementers
go through the pain and performance hit of getattr or dictate an implementation
(like caching attributes or otherwise directly storing them, creating
memory leaks).

Jim
 

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.