When loading YAML data using ruamel.yaml, anchors and their aliases in the YAML file are the same object in Python:
from ruamel.yaml import YAML
yaml_str = """\
first: &reference [1, 2, 3]
second: *reference
"""
yaml = YAML()
data = yaml.load(yaml_str)
assert(data['first'] is data['second'])
# passes
data['first'].append(4)
print(data['second'])
# output: [1, 2, 3, 4]
I realize this is an intentional feature. However, is there a way to tell load to instead copy aliases when it finds them? I tried overriding yaml.representer.ignore_aliases as mentioned in this answer, but that's only for writing to YAML, not reading from it.