Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Newbie Question: can this snippet be optimized? (http://www.velocityreviews.com/forums/t318832-newbie-question-can-this-snippet-be-optimized.html)

Hedr 06-25-2003 03:08 PM

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

Raymond Hettinger 06-25-2003 03:44 PM

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 05:29 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.