I use ElementTree as a my python xml util. But recently I had a problem in a time to write it. In my code, it gather about a 10MB data and write it end of the code. So it takes around 10 to 12 seconds. But within progress, writing progress take about 8 to 10 seconds.
I hope to change my code to save time. As a normal file write code, is there any library it works in a non-linear manner?
Added
Usually I write like below
from xml.etree.cElementTree import Element, ElementTree
rootEm = Element("root")
childEm1 = Element("child1")
rootEm.append(childEm1)
childEm2 = Element("child2")
rootEm.append(childEm2)
ElementTree(rootEm).write(filename) ## I always save it at the last time of process
But I want work like this
import SOMEXMLWRITER
_f = open(filename, "w") ## open file first
writer = SOMEXMLWRITER(_f)
rootEm = Element("root") ## add Element at that time
writer.addXMLDocument(rootEm)
childEm1 = Element("child1")
rootEm.append(childEm1)
childEm2 = Element("child2")
rootEm.append(childEm2)
_f.close() ## just close file... DONE!