[XML-SIG] Specializing DOM exceptions

Fred L. Drake, Jr. fdrake@acm.org
Wed, 3 Jan 2001 12:48:20 -0500 (EST)


Mike Olson writes:
 > Actually there may be a small performace advantage doing it they way it
 > is done.  Looking it up from the instance it will have to look into
 > atleast 3 dictionaries to find the value, while looking it up from the
 > class itself it will only have to look into one dictionary.  (though
 > this theroy is untested)

Mike,
  It doesn't quite work like that -- looking it up from the class only
takes one dict lookup *once you have the class*, but you are also
doing one lookup for the class itself, assuming you've imported it
into your module's globals.  So the difference is a single dictionary
lookup for each level of class derivation from Node.  For interned
strings, this is pretty trivial and you can reasonably expect it to
disappear in the wash.
  On the other hand, picking it up from the class does assure you know
the exact access path, and some people think it's more readable.
"from xml.dom import Node" is your friend.  ;-)


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Digital Creations