![]() |
Newbie Question: can this snippet be optimized?
Hi Pythonians,
The underlying snippet is copied from minidom.py which is in the XML package which I am currently using. Cloning nodes seem to take a considerable amount of time, hence I went looking in the code whether optimizations could be made. The following snippet contains a for loop: def cloneNode(self, deep): clone = Node.cloneNode(self, deep) clone._attrs = {} clone._attrsNS = {} for attr in self._attrs.values(): node = attr.cloneNode(1) clone._attrs[node.name] = node clone._attrsNS[(node.namespaceURI, node.localName)] = node node.ownerElement = clone return clone I just wondered if this could be optimized (mao, array, whatever) and if so, how? I do not have much experience with Python, hence the question. Thanks for suggestions, Hedr |
Re: Newbie Question: can this snippet be optimized?
<Hedr> wrote in message news:3ef9ba07.117801375@news.skynet.be...
> Hi Pythonians, > > The underlying snippet is copied from minidom.py which is in the XML > package which I am currently using. Cloning nodes seem to take a > considerable amount of time, hence I went looking in the code whether > optimizations could be made. Try applying psyco.bind() to see if you can get a substantial speed-up. Raymond Hettinger |
| All times are GMT. The time now is 03:52 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.