On 10/02/2022 21:43, Friedrich Rentsch wrote:
I believe to have observed a difference which also might be worth noting: the imbedded function a() (second example) has access to all of the imbedding function's variables, which might be an efficiency factor with lots of variables. The access is read-only, though. If the inner function writes to one of the readable external variables, that variable becomes local to the inner function.
You can make it continue to refer to the variables of the imbedding function, i.e. b(), by declaring them non-local, e.g.
    nonlocal c
Rob Cliffe


Frederic

On 2/10/22 1:13 PM, BlindAnagram wrote:
Is there any difference in performance between these two program layouts:

   def a():
     ...
   def(b):
     c = a(b)

or

   def(b):
     def a():
       ...
     c = a(b)

I would appreciate any insights on which layout to choose in which circumstances.



--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to