Hi all,
Is it efficient to pass an object returned by lxml.etree.parse("a.xml") as argument to other functions? Is the object returned a C pointer-like mechanism referring to the in-memory tree representation of XML? Or is it something else? Will it cause any performance issues down the line? I expect the size of the tree when taken in-memory could be around 15 MB.
I am planning to write multiple functions to process each child node and its sub-child nodes. To each function. I will be passing the object corresponding to child node.
Thanks
Sandeep
You can think of all Python variables as pointers. Passing parameters won't be a problem. You can test this yourself too, if you'd like, by passing a list to a function, mutating it within the function (without returning it), and observing the side effect outside the function as evidence that the same object was passed around.
(Oct-11-2016, 07:39 AM)sandeepvl Wrote: [ -> ]Hi all,
Is it efficient to pass an object returned by lxml.etree.parse("a.xml") as argument to other functions? Is the object returned a C pointer-like mechanism referring to the in-memory tree representation of XML? Or is it something else? Will it cause any performance issues down the line? I expect the size of the tree when taken in-memory could be around 15 MB.
I am planning to write multiple functions to process each child node and its sub-child nodes. To each function. I will be passing the object corresponding to child node.
Thanks
Sandeep
Definitely the most complete answer you'll get on the subject:
(Oct-11-2016, 09:13 PM)Ofnuts Wrote: [ -> ] (Oct-11-2016, 07:39 AM)sandeepvl Wrote: [ -> ]Hi all,
Is it efficient to pass an object returned by lxml.etree.parse("a.xml") as argument to other functions? Is the object returned a C pointer-like mechanism referring to the in-memory tree representation of XML? Or is it something else? Will it cause any performance issues down the line? I expect the size of the tree when taken in-memory could be around 15 MB.
I am planning to write multiple functions to process each child node and its sub-child nodes. To each function. I will be passing the object corresponding to child node.
Thanks
Sandeep
Definitely the most complete answer you'll get on the subject:
Thanks a lot for that video. It helped a lot. Really an eye opener.