Python Forum
Effeciency of passing XML tree object as function arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Effeciency of passing XML tree object as function arguments
#1
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
Reply
#2
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.
Reply
#3
(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:

Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#4
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Passing writable arguments to functions. Assembler 11 820 Jan-15-2024, 11:32 PM
Last Post: sgrey
  calling external function with arguments Wimpy_Wellington 7 1,344 Jul-05-2023, 06:33 PM
Last Post: deanhystad
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,211 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  passing dictionary to the function mark588 2 932 Dec-19-2022, 07:28 PM
Last Post: deanhystad
  Passing string functions as arguments Clunk_Head 3 1,207 Jun-15-2022, 06:00 AM
Last Post: Gribouillis
  AttributeError: 'function' object has no attribute 'metadata 3lnyn0 5 4,522 Mar-28-2022, 04:42 PM
Last Post: Larz60+
  'namespace' shorthand for function arguments? shadowphile 5 2,541 Aug-11-2021, 09:02 PM
Last Post: shadowphile
  Checking the number of arguments a function takes Chirumer 3 2,111 Jul-06-2021, 04:56 PM
Last Post: Chirumer
  Passing flags to python script, through a function xbit 4 3,874 Apr-20-2021, 06:32 AM
Last Post: ndc85430
  how to call an object in another function in Maya bstout 0 2,042 Apr-05-2021, 07:12 PM
Last Post: bstout

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020