forked from VimPlug/jedi
removed duplicate fast_parent_copy method, now its used for Calls and Scopes
This commit is contained in:
@@ -663,7 +663,7 @@ class Execution(Executable):
|
|||||||
for element in attr:
|
for element in attr:
|
||||||
temp, element.parent = element.parent, None
|
temp, element.parent = element.parent, None
|
||||||
#copied = copy.deepcopy(element)
|
#copied = copy.deepcopy(element)
|
||||||
copied = helpers.fast_parent_copy2(element)
|
copied = helpers.fast_parent_copy(element)
|
||||||
element.parent = temp
|
element.parent = temp
|
||||||
copied.parent = weakref.ref(self)
|
copied.parent = weakref.ref(self)
|
||||||
if isinstance(copied, parsing.Function):
|
if isinstance(copied, parsing.Function):
|
||||||
|
|||||||
39
helpers.py
39
helpers.py
@@ -75,44 +75,11 @@ class RecursionNode(object):
|
|||||||
and self.position == other.position and not self.is_ignored
|
and self.position == other.position and not self.is_ignored
|
||||||
|
|
||||||
|
|
||||||
def fast_parent_copy_old(obj):
|
|
||||||
"""
|
|
||||||
Much, much faster than deepcopy, but just for the elements in `classes`.
|
|
||||||
"""
|
|
||||||
new_elements = {}
|
|
||||||
classes = (parsing.Call, parsing.Scope)
|
|
||||||
|
|
||||||
def recursion(obj):
|
|
||||||
new_obj = copy.copy(obj)
|
|
||||||
new_elements[obj] = new_obj
|
|
||||||
if obj.parent is not None:
|
|
||||||
try:
|
|
||||||
new_obj.parent = weakref.ref(new_elements[obj.parent()])
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
#print new_obj.__dict__
|
|
||||||
for key, value in new_obj.__dict__.items():
|
|
||||||
if isinstance(value, list):
|
|
||||||
new_obj.__dict__[key] = list_rec(value)
|
|
||||||
return new_obj
|
|
||||||
|
|
||||||
def list_rec(list_obj):
|
|
||||||
copied_list = list_obj[:] # lists, tuples, strings, unicode
|
|
||||||
for i, el in enumerate(copied_list):
|
|
||||||
if isinstance(el, classes):
|
|
||||||
copied_list[i] = recursion(el)
|
|
||||||
elif isinstance(el, list):
|
|
||||||
copied_list[i] = list_rec(el)
|
|
||||||
return copied_list
|
|
||||||
return recursion(obj)
|
|
||||||
|
|
||||||
def fast_parent_copy(obj):
|
def fast_parent_copy(obj):
|
||||||
"""
|
"""
|
||||||
Much, much faster than deepcopy, but just for the elements in `classes`.
|
Much, much faster than deepcopy, but just for the elements in `classes`.
|
||||||
"""
|
"""
|
||||||
new_elements = {}
|
new_elements = {}
|
||||||
classes = (parsing.Simple, parsing.Call)
|
|
||||||
|
|
||||||
def recursion(obj):
|
def recursion(obj):
|
||||||
new_obj = copy.copy(obj)
|
new_obj = copy.copy(obj)
|
||||||
@@ -130,20 +97,20 @@ def fast_parent_copy(obj):
|
|||||||
continue
|
continue
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
new_obj.__dict__[key] = list_rec(value)
|
new_obj.__dict__[key] = list_rec(value)
|
||||||
elif isinstance(value, classes):
|
elif isinstance(value, parsing.Simple):
|
||||||
new_obj.__dict__[key] = recursion(value)
|
new_obj.__dict__[key] = recursion(value)
|
||||||
return new_obj
|
return new_obj
|
||||||
|
|
||||||
def list_rec(list_obj):
|
def list_rec(list_obj):
|
||||||
copied_list = list_obj[:] # lists, tuples, strings, unicode
|
copied_list = list_obj[:] # lists, tuples, strings, unicode
|
||||||
for i, el in enumerate(copied_list):
|
for i, el in enumerate(copied_list):
|
||||||
if isinstance(el, classes):
|
if isinstance(el, (parsing.Simple, parsing.Call)):
|
||||||
copied_list[i] = recursion(el)
|
copied_list[i] = recursion(el)
|
||||||
elif isinstance(el, list):
|
elif isinstance(el, list):
|
||||||
copied_list[i] = list_rec(el)
|
copied_list[i] = list_rec(el)
|
||||||
return copied_list
|
return copied_list
|
||||||
return recursion(obj)
|
return recursion(obj)
|
||||||
fast_parent_copy2 = fast_parent_copy
|
|
||||||
|
|
||||||
def generate_param_array(args_tuple, parent_stmt=None):
|
def generate_param_array(args_tuple, parent_stmt=None):
|
||||||
""" This generates an array, that can be used as a param """
|
""" This generates an array, that can be used as a param """
|
||||||
|
|||||||
Reference in New Issue
Block a user