diff options
author | 2018-09-21 07:19:09 -0700 | |
---|---|---|
committer | 2018-09-21 07:23:15 -0700 | |
commit | 035a84769de2921667677b5530011bbd558ddf0c (patch) | |
tree | 3ff81e7ff0a6e50bd5b04fa486d173e0231ade54 /tensorflow/python/autograph/pyct/static_analysis/activity.py | |
parent | 200b89761a4665e3de6d0efc4e3e10ab287ad81b (diff) |
Use weakrefs where absolutely safe to do so, in order to reduce the number of circular references. Replace unnecessary OrderedDict with a regular dict.
PiperOrigin-RevId: 213982097
Diffstat (limited to 'tensorflow/python/autograph/pyct/static_analysis/activity.py')
-rw-r--r-- | tensorflow/python/autograph/pyct/static_analysis/activity.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tensorflow/python/autograph/pyct/static_analysis/activity.py b/tensorflow/python/autograph/pyct/static_analysis/activity.py index 9cb5991322..086eda7574 100644 --- a/tensorflow/python/autograph/pyct/static_analysis/activity.py +++ b/tensorflow/python/autograph/pyct/static_analysis/activity.py @@ -22,6 +22,7 @@ from __future__ import division from __future__ import print_function import copy +import weakref import gast @@ -126,7 +127,10 @@ class Scope(object): self.parent.mark_read(name) def mark_param(self, name, owner): - self.params[name] = owner + # Assumption: all AST nodes have the same life span. This lets us use + # a weak reference to mark the connection between a symbol node and the + # function node whose argument that symbol is. + self.params[name] = weakref.ref(owner) def mark_creation(self, name, writes_create_symbol=False): """Mark a qualified name as created.""" |