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.
as define function or method (which nothing bound function), python creates function instance. happens when code run first time.
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
Post a Comment