I think you missed something in your post, your code would throw syntax error.
Let's say you wrote what I assume is the right code:
class ObjectA(object):
def __init__(self):
self.some_member = "some_value"
def get_some_result(self):
return self.some_member
if __name__ == "__main__":
# This would create an instance of ObjectA in memory,
# then call get_some_result() and assign the result (reference)
# to the variable a
a = ObjectA().get_some_result()
# This will create a new ObjectA in memory
# then call get_some_result() and assign the result (reference)
# as a parameter of deepcopy.
# in this case the constructor of the object assigns a fixed value,
# so python just stores the string 'some value' as a const value in the memory
# and the string object is actually always the same
a = copy.deepcopy(ObjectA().get_some_result())
# Example:
obj1 = ObjectA()
obj2 = ObjectA()
print(id(obj1)) # 4561426512
print(id(obj2)) # 4562720224
print(id(ObjectA()) # 4594936224
print(id(ObjectA()) # 4594869824
print(id(obj1.get_some_result())) # 4562116656
print(id(obj2.get_some_result())) # 4562116656
Also reading from the docs it seems that in certain cases deepcopy would just return the reference and not create a new object.
from: https://docs.python.org/3/library/copy.html
Because deep copy copies everything it may copy too much, such as data which is intended to be shared between copies.
Also, strings behave like this (are immutable):
>>> a = "strawberry"
>>> b = "strawberry"
>>> id(a) == id(b)
True
>>> a = "strawberry"
>>> b = "Strawberry"
>>> id(a) == id(b)
False
A different story if the value assigned to the member is a mutable object.