10 May
2006
10 May
'06
3:27 p.m.
Steve Howe wrote:
Huh? Have you noticed that tostring takes an optional encoding argument?
Won't that waste exactly the same resources as this ?
xml = etree.tostring(element).encode(encoding)
tostring returns encoded data. did you mean xml = etree.tounicode(element).encode(encoding) ? if so, the answer is no -- the serializer encodes the infoset piece by piece, using different approaches for different parts of the infoset (at least that's what the ET serializer does; not sure about lxml). there's some overhead from cStringIO, though, but that should be far from the 3x/5x worst-case overhead in your example. (and for western users, the worst case is quite often the typical case) </F>