summaryrefslogtreecommitdiffstats
path: root/Lib/xml/dom/expatbuilder.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2012-02-19 19:25:12 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2012-02-19 19:25:12 (GMT)
commit14aa280de23ecb6c31ffbde4a12c1a0a6f5493e0 (patch)
treea6272d0d650f428339f265e22b8687df767b600f /Lib/xml/dom/expatbuilder.py
parent32ac92cd4a341fc2503305b3017d2262c203558e (diff)
downloadcpython-14aa280de23ecb6c31ffbde4a12c1a0a6f5493e0.zip
cpython-14aa280de23ecb6c31ffbde4a12c1a0a6f5493e0.tar.gz
cpython-14aa280de23ecb6c31ffbde4a12c1a0a6f5493e0.tar.bz2
Use __slots__ throughout instead of __dict__, to reduce the memory usage.
Diffstat (limited to 'Lib/xml/dom/expatbuilder.py')
-rw-r--r--Lib/xml/dom/expatbuilder.py39
1 files changed, 13 insertions, 26 deletions
diff --git a/Lib/xml/dom/expatbuilder.py b/Lib/xml/dom/expatbuilder.py
index a98fe03..b4b28e4 100644
--- a/Lib/xml/dom/expatbuilder.py
+++ b/Lib/xml/dom/expatbuilder.py
@@ -283,27 +283,23 @@ class ExpatBuilder:
elif childNodes and childNodes[-1].nodeType == TEXT_NODE:
node = childNodes[-1]
value = node.data + data
- d = node.__dict__
- d['data'] = d['nodeValue'] = value
+ node.data = value
return
else:
node = minidom.Text()
- d = node.__dict__
- d['data'] = d['nodeValue'] = data
- d['ownerDocument'] = self.document
+ node.data = data
+ node.ownerDocument = self.document
_append_child(self.curNode, node)
def character_data_handler(self, data):
childNodes = self.curNode.childNodes
if childNodes and childNodes[-1].nodeType == TEXT_NODE:
node = childNodes[-1]
- d = node.__dict__
- d['data'] = d['nodeValue'] = node.data + data
+ node.data = node.data + data
return
node = minidom.Text()
- d = node.__dict__
- d['data'] = d['nodeValue'] = node.data + data
- d['ownerDocument'] = self.document
+ node.data = node.data + data
+ node.ownerDocument = self.document
_append_child(self.curNode, node)
def entity_decl_handler(self, entityName, is_parameter_entity, value,
@@ -363,11 +359,8 @@ class ExpatBuilder:
a = minidom.Attr(attributes[i], EMPTY_NAMESPACE,
None, EMPTY_PREFIX)
value = attributes[i+1]
- d = a.childNodes[0].__dict__
- d['data'] = d['nodeValue'] = value
- d = a.__dict__
- d['value'] = d['nodeValue'] = value
- d['ownerDocument'] = self.document
+ a.value = value
+ a.ownerDocument = self.document
_set_attribute_node(node, a)
if node is not self.document.documentElement:
@@ -761,11 +754,8 @@ class Namespaces:
else:
a = minidom.Attr("xmlns", XMLNS_NAMESPACE,
"xmlns", EMPTY_PREFIX)
- d = a.childNodes[0].__dict__
- d['data'] = d['nodeValue'] = uri
- d = a.__dict__
- d['value'] = d['nodeValue'] = uri
- d['ownerDocument'] = self.document
+ a.value = uri
+ a.ownerDocuemnt = self.document
_set_attribute_node(node, a)
del self._ns_ordered_prefixes[:]
@@ -785,12 +775,9 @@ class Namespaces:
aname, EMPTY_PREFIX)
_attrs[aname] = a
_attrsNS[(EMPTY_NAMESPACE, aname)] = a
- d = a.childNodes[0].__dict__
- d['data'] = d['nodeValue'] = value
- d = a.__dict__
- d['ownerDocument'] = self.document
- d['value'] = d['nodeValue'] = value
- d['ownerElement'] = node
+ a.ownerDocument = self.document
+ a.value = value
+ a.ownerElement = node
if __debug__:
# This only adds some asserts to the original