twonds / punjab

BOSH connection manager
MIT License
183 stars 49 forks source link

Don't build whole xml tree for stanza payload #65

Closed olruzhytskyi closed 7 years ago

olruzhytskyi commented 7 years ago

Some stanzas (with roster for example) can contain huge amount of xml, which is all parsed into xml tree even if use_raw=True. Because of this punjab can consume large amount of RAM (possibly because of python memory fragmentation http://www.gossamer-threads.com/lists/python/python/1162114) and CPU (to create domish.Element() instances).

ShallowExpatElementStream overrides _onStartElement() and _onEndElement() methods of regular parser to avoid building whole tree, which is done by default in domish.py:ExpatElementStream.

twonds commented 7 years ago

Thanks for this, I will look at it as soon as I can.