Python-Function object creation -


as understand book function in python nothing object of function class. have doubts below:

1.when object gets created? @ time define function or @ time call function?

2.if getting created @ time define function, not waste of memory if not call function anywhere in program ?

looking detail answer.

  1. as define function or method (which nothing bound function), python creates function instance. happens when code run first time.

  2. yes, "waste" of memory, consider how memory compared big arrays, binary files etc. python not performant or resource-light language/interpreter, saves lots of time on writing code (because write less) , caring optimisation (you don't). mean seriously, few kb in file size matter nowadays? surely loss in value less minute of attention.

    the reason unused functions can't optimised away might used later on in same script or other scripts.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -