Facundo Batista <facu...@taniquetil.com.ar> added the comment:

Making a copy of f_locals values to return a dictionary that doesn't hold 
references to the locals of the frame is not that simple (for me, at least):

- shallow copy: we'll return always a new dict, with the values being a copy of 
locals; this is simpler, but what about other objects that are referenced in in 
those values? For example, in locals exists a list A which holds a reference to 
object B; the new dict we return will have copy of A, but this copy will still 
reference B.

- deep copy: we'll return a new dict with a deep copy of all values; this is 
safer, but what about memory? In any case, how we could do a deep copy here? 
calling Python's code copy.deepcopy()?

I want to add a fourth option to JP's initial ones:

- have other attribute, something like f_locals_weak that is a list of tuples 
[(name, value), ...], being the values a weak reference to the real locals.

What do you think?

Regards,

----------
nosy: +facundobatista

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6116>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to