Message135210
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, |
|
Date |
User |
Action |
Args |
2011-05-05 14:46:00 | facundobatista | set | recipients:
+ facundobatista, exarkun, pitrou, vstinner |
2011-05-05 14:46:00 | facundobatista | set | messageid: <1304606760.56.0.825883382704.issue6116@psf.upfronthosting.co.za> |
2011-05-05 14:45:58 | facundobatista | link | issue6116 messages |
2011-05-05 14:45:58 | facundobatista | create | |
|