This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Robert Haschke
Recipients Robert Haschke
Date 2015-06-10.13:29:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1433942956.66.0.599460998017.issue24424@psf.upfronthosting.co.za>
In-reply-to
Content
Node.insertBefore() has a serious performance issue:

Using self.childNodes.index(refChild) it searches for the correct index in childNodes where the newChild should be inserted.
However, index() is linear in time w.r.t. the size of childNodes.
Hence, if there are many children, runtime dramatically increases.

Adding a simple caching mechanism (caching the previously used reference)
I was able to reduce runtime in my particular case from 16s to 1.6s, i.e. a factor of 10!
History
Date User Action Args
2015-06-10 13:29:16Robert Haschkesetrecipients: + Robert Haschke
2015-06-10 13:29:16Robert Haschkesetmessageid: <1433942956.66.0.599460998017.issue24424@psf.upfronthosting.co.za>
2015-06-10 13:29:16Robert Haschkelinkissue24424 messages
2015-06-10 13:29:16Robert Haschkecreate