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 03:52 AM.

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57